Beispiel #1
0
void 	load_all_section(Elf64_Ehdr *header, char *file, t_section *sections)
{
  load_section(header, file, "hidden1", sections);
  load_section(header, file, "hidden2", sections + 1);
  load_section(header, file, "hidden3", sections + 2);
  load_section(header, file, "demochescene", sections + 3);
}
Beispiel #2
0
enum armv2_status load_rom(struct armv2 *cpu, const char *filename) {
    FILE              *f          = NULL;
    enum armv2_status  retval     = ARMV2STATUS_OK;
    struct stat        st         = {0};

    if(NULL == cpu) {
        return ARMV2STATUS_OK;
    }

    if(!(cpu->flags&FLAG_INIT)) {
        return ARMV2STATUS_INVALID_CPUSTATE;
    }

    if(NULL == cpu->page_tables[0] || NULL == cpu->page_tables[0]->memory) {
        return ARMV2STATUS_INVALID_CPUSTATE;
    }

    if(0 != stat(filename,&st)) {
        return ARMV2STATUS_IO_ERROR;
    }

    ssize_t size = st.st_size;
    if(size < 28) {
        //28 is the bare minimum for a rom, as the vectors go up to
        //0x20, and then you need at least one instruction, and the
        //first word is the length
        return ARMV2STATUS_IO_ERROR;
    }

    f = fopen(filename,"rb");
    if(NULL == f) {
        LOG("Error opening %s\n",filename);
        return ARMV2STATUS_IO_ERROR;
    }

    retval = load_section( cpu, BOOT_ROM_ADDR, TAPE_ADDR, f, &size );
    if( ARMV2STATUS_OK != retval ) {
        LOG("Error loading boot rom section\n");
        goto close_file;
    }

    retval = load_section( cpu, SYMBOLS_ADDR, SYMBOLS_ADDR + MAX_SYMBOLS_SIZE, f, &size );
    if( ARMV2STATUS_OK != retval ) {
        LOG("Error loading boot rom symbols\n");
        goto close_file;
    }

close_file:
    fclose(f);
    return retval;
}
Beispiel #3
0
Datei: bbsnet.c Projekt: wyat/kbs
void main_loop()
{
    int i;
    POINT pts[MAXSTATION];
    struct _select_def bbsnet_conf;

    for (i = 0; i < MAXSTATION; i++) {
        pts[i].x = 2 + ((i>=17)?20:0) + ((i>=34)?20:0) + ((i>=51)?20:0);
        pts[i].y = i + 2 -((i>=17)?17:0) - ((i>=34)?17:0) - ((i>=51)?17:0);
    };

    sectionindex=1;
    bzero(&bbsnet_conf,sizeof(bbsnet_conf));
    load_section(&bbsnet_conf,1,MAXSTATION);
    bbsnet_conf.item_per_page = bbsnet_conf.item_count;
    bbsnet_conf.flag = LF_FORCEREFRESHSEL | LF_BELL | LF_LOOP;     //|LF_HILIGHTSEL;
    bbsnet_conf.prompt = NULL;
    bbsnet_conf.item_pos = pts;
    bbsnet_conf.arg = NULL;
    bbsnet_conf.title_pos.x = 0;
    bbsnet_conf.title_pos.y = 0;
    bbsnet_conf.pos = 1;
    bbsnet_conf.page_pos = 1;

    bbsnet_conf.on_select = bbsnet_onselect;
    bbsnet_conf.show_data = bbsnet_show;
    bbsnet_conf.key_command = bbsnet_key;
    bbsnet_conf.show_title = bbsnet_refresh;
    bbsnet_conf.get_data = load_section;
    bbsnet_conf.on_selchange = bbsnet_selchange;
    list_select_loop(&bbsnet_conf);
}
Beispiel #4
0
void load_items_dat(char *name)
  {
  FILE *f;
  void *temp;
  int type;
  long size;

  f=fopen(name,"rb");
  if (f==NULL)
     {
     printf("Nemohu otevrit soubor %s\n",name);
     exit(1);
     }
  do
     {
     load_section(f,&temp,&type,&size);
     switch (type)
        {
        case SV_ITLIST:itlist=temp;item_count=size/sizeof(TITEM);break;
        case SV_SNDLIST:sound=temp;listsize=size;break;

        case SV_END:
        default: free(temp);break;
        }
     }
  while (type!=SV_END);
  fclose(f);
  }
Beispiel #5
0
void CDamageManager::reload				(LPCSTR section,CInifile* ini)
{
	m_default_hit_factor	= 1.f;
	m_default_wound_factor	= 1.f;

	bool section_exist		= ini && ini->section_exist(section);
	
	// прочитать дефолтные параметры
	if (section_exist) {
		string32 buffer;
		if (ini->line_exist(section,"default")) {
			LPCSTR value			= ini->r_string(section,"default");
			m_default_hit_factor	= (float)atof(_GetItem(value,0,buffer));
			m_default_wound_factor  = (float)atof(_GetItem(value,2,buffer));
		}
	}

	//инициализировать default параметрами
	init_bones		(section,ini);

	// записать поверху прописанные параметры
	if (section_exist) {
		load_section	(section,ini);
	}
}
int load_buffer(unsigned char *buf, struct audit_log_entry_t *audit_log)
{
    int count = 0;
    int buf_len = strlen(buf);
    char *mark = NULL;

    audit_log->section_a = NULL;
    audit_log->section_b = NULL;
    audit_log->section_f = NULL;
    audit_log->section_e = NULL;
    audit_log->section_h = NULL;

    /* finding the separator */
    while (buf_len > count && buf[count] != '\n')
    {
        count++;
    }

    if (buf[count] != '\n')
    {
        fprintf(stderr, "Not an valid audit log entry");
        return -1;
    }

    mark = malloc(sizeof(char) * (count - 3 + 1));
    memset(mark, '\0', count - 3 + 1);
    mark = strncpy(mark, buf, count - 3);

    audit_log->mark = mark;
    audit_log->buf = buf;
    audit_log->buf_len = buf_len;

    audit_log->section_a = load_section('A', audit_log);
    audit_log->section_b = load_section('B', audit_log);
    audit_log->section_f = load_section('F', audit_log);
    audit_log->section_e = load_section('E', audit_log);
    audit_log->section_h = load_section('H', audit_log);

    parse_section_a(audit_log->section_a, audit_log);

    return 0;
}
Beispiel #7
0
void GameBody :: set_value(int max){
    gamesection = 0;
    max_sec_num = max;
    current_sec = 0;
    gamesection = 0;
    last_active_unit = 0;
    cursor = QPoint(0,0);
    show_cursor = false;
    random_size = 5;
    random_colortype = 3;
    load_section(current_sec);
}
int coff_extract(FILE *in, binfile_imgcb_t cb, void *user_data)
{
	struct coff_header hdr;
	uint8_t *shdrs;
	int ret = 0;
	int i;

	if (read_header(in, &hdr) < 0)
		return -1;

	if (read_sechdrs(in, &hdr, &shdrs) < 0)
		return -1;

	for (i = 0; i < hdr.sec_count; i++) {
		uint8_t *header = shdrs + SHDR_SIZE * i;
		uint32_t flags = LE_LONG(header, 40);

		if (((flags & STYP_TEXT) || (flags & STYP_DATA)) &&
		    !(flags & STYP_NOLOAD)) {
			uint32_t addr = LE_LONG(header, 8);
			uint32_t offset = LE_LONG(header, 20);
			uint32_t size = LE_LONG(header, 16);

			if (load_section(in, addr, offset, size,
					 cb, user_data) < 0) {
				printc_err("coff: error while loading "
					"section %d\n", i);
				ret = -1;
				break;
			}
		}
	}

	if (shdrs)
		free(shdrs);

	return ret;
}
Beispiel #9
0
static int load_sections(struct proc_info * proc, file_t * file,
                         struct elf32_header * elfhdr, struct elf32_phdr * phdr,
                         uintptr_t rbase, uintptr_t * vaddr_base)
{
    int e_type = elfhdr->e_type;
    size_t phnum = elfhdr->e_phnum;

    for (size_t i = 0; i < phnum; i++) {
        struct buf * sect;
        int err;

        if (!(phdr[i].p_type == PT_LOAD && phdr[i].p_memsz != 0))
            continue;

        if ((err = load_section(&sect, file, rbase, &phdr[i])))
            return err;

        if (e_type == ET_EXEC && i < 2) {
            const int reg_nr = (i == 0) ? MM_CODE_REGION : MM_HEAP_REGION;

            if (i == 0)
                *vaddr_base = phdr[i].p_vaddr + rbase;
            err = vm_replace_region(proc, sect, reg_nr, VM_INSOP_MAP_REG);
            if (err) {
                KERROR(KERROR_ERR, "Failed to replace a region\n");
                return err;
            }
        } else {
            err = vm_insert_region(proc, sect, VM_INSOP_MAP_REG);
            if (err < 0) {
                KERROR(KERROR_ERR, "Failed to insert a region\n");
                return -1;
            }
        }
    }

    return 0;
}
Beispiel #10
0
void GameBody :: past_sec(){
    if (current_sec>0){
        current_sec--;
        load_section(current_sec);
    }
}
Beispiel #11
0
void GameBody :: next_sec(){
    if (current_sec<max_sec_num-1){
        current_sec++;
        load_section(current_sec);
    }
}
Beispiel #12
0
/*
    bool load(const char * key, const std::string value)
    {
        std::string skey(key);
        return search_and_apply(skey, value, load_section(skey, value));
    }
*/
    bool load(const std::string & key, const std::string & value)
    {
        return search_and_apply(key, value, load_section(key, value));
    }
Beispiel #13
0
void load_config_encode()
{
struct encodingoptions *point;
struct machine *pointm;
char filename[100];
char section[LONGOPT];
int have_config;

  sprintf(filename,"%s/%s/%s",getenv("HOME"),".studio", encodeconfigfile );
  if (0 == cfg_parse_file(filename))
    have_config = 1;

  point = &encoding; 
  set_structs_default(point);  /* set struct to the defaults */

  point = &encoding2;
  set_structs_default(point);  /* set struct to the defaults */
  do_preset_mpeg2(point);     /* set some mpeg2 specific options */

  point = &encoding_gmpeg;
  set_structs_default(point);  /* set struct to the defaults */
  do_preset_mpeg2(point);     /* set some mpeg2 specific options */

  point = &encoding_vcd;
  set_structs_default(point);  /* set struct to the defaults */
  do_preset_vcd(point);     /* set some VCD specific options */

  point = &encoding_svcd;
  set_structs_default(point);  /* set struct to the defaults */
  do_preset_svcd(point);     /* set some SVCD specific options */

  point = &encoding_dvd;
  set_structs_default(point);  /* set struct to the defaults */
  do_preset_dvd(point);     /* set some DVD specific options */

  point = &encoding_yuv2lav;
  set_structs_default(point);  /* set struct to the defaults */
  do_preset_yuv2lav(point);     /* set some DIVX specific options */

  set_distributed(); /*set the distributed encoding variabels to the defaults*/

  /* set the defaults for the scripting options */
  set_scripting_defaults ();

  set_common();
  load_common();
  
  if (verbose)
    show_common();

  strncpy(section,"MPEG1",LONGOPT);
  point = &encoding; 
  load_section(section,point);
  if (verbose) 
    print_encoding_options(section,point);

  strncpy(section,"MPEG2",LONGOPT);
  point = &encoding2; 
  load_section(section,point);
  if (verbose)
    print_encoding_options(section,point);

  strncpy(section,"GENERIC",LONGOPT);
  point = &encoding_gmpeg; 
  load_section(section,point);
  if (verbose)
    print_encoding_options(section,point);

  strncpy(section,"VCD",LONGOPT);
  point = &encoding_vcd; 
  load_section(section,point);
  if (verbose)
    print_encoding_options(section,point);

  strncpy(section,"SVCD",LONGOPT);
  point = &encoding_svcd; 
  load_section(section,point);
  if (verbose)
    print_encoding_options(section,point);

  strncpy(section,"DVD",LONGOPT);
  point = &encoding_dvd; 
  load_section(section,point);
  if (verbose)
    print_encoding_options(section,point);

  strncpy(section,"YUV2LAV",LONGOPT);
  point = &encoding_yuv2lav; 
  load_section(section,point);
  if (verbose)
    print_encoding_options(section,point);

  load_machine_names();  /* fill the GList with machine names */
  if (verbose)
    print_machine_names(); 
 
  strncpy(section,"Machines4MPEG1",LONGOPT);
  pointm = &machine4mpeg1; 
  load_machine_data(section, pointm);
  if (verbose)
    print_machine_data(section,pointm);

  strncpy(section,"Machines4MPEG2",LONGOPT);
  pointm = &machine4mpeg2; 
  load_machine_data(section, pointm);
  if (verbose)
    print_machine_data(section,pointm);

  strncpy(section,"Machines4GENERIC",LONGOPT);
  pointm = &machine4mpeg2; 
  load_machine_data(section, pointm);
  if (verbose)
    print_machine_data(section,pointm);

  strncpy(section,"Machines4VCD",LONGOPT);
  pointm = &machine4vcd; 
  load_machine_data(section, pointm);
  if (verbose)
    print_machine_data(section,pointm);

  strncpy(section,"Machines4SVCD",LONGOPT);
  pointm = &machine4svcd; 
  load_machine_data(section, pointm);
  if (verbose)
    print_machine_data(section,pointm);

  strncpy(section,"Machines4DVD",LONGOPT);
  pointm = &machine4svcd; 
  load_machine_data(section, pointm);
  if (verbose)
    print_machine_data(section,pointm);

  strncpy(section,"Machines4YUV2LAV",LONGOPT);
  pointm = &machine4yuv2lav; 
  load_machine_data(section, pointm);
  if (verbose)
    print_machine_data(section,pointm);

  load_script_data();

}
Beispiel #14
0
int load_map(char *filename)
  {
  FILE *f;
  void *temp;
  int sect,i;
  long size,r;
  char nmapend=1;
  static char las=1;
  static char newcode=0;

  passpass=0;
  purge_mob_map();
  if (las)
     {
     if (check_sound_map())
        msg_box("Upozorn�n�!",'\x1',"Verze souboru SOUND.DAT neodpovid� verz�m ostatn�ch soubor�. To m��e zp�sobit poru�en� integrity ukazatel� na zvukov� soubory!","Pokra�ovat",NULL);
     load_all_shops();
     las=0;
     }
  load_mobs();
  load_sound_map();
  load_items();
  password[0]=0;
  f=fopen(filename,"rb");
  if (f==NULL) return 0;
  do
     {
     r=load_section(f,&temp,&sect,&size);
     if (r==size)
        switch (sect)
         {
         case A_SIDEMAP:
                  memcpy(&mapa.sidedef,temp,size);
                  break;
         case A_SECTMAP:
                  memcpy(&mapa.sectordef,temp,size);
                  break;
         case A_MAPGLOB:
                  memset(&mglob,0,sizeof(mglob));
                  if (size>sizeof(mglob)) size=sizeof(mglob);
                  memcpy(&mglob,temp,size);
/*                  if (size>sizeof(mglob)-sizeof(mglob.mappassw))
                    {
                    decrypt2(mglob.mappassw,password);
                    passpass=2;
                    if (password[0]) newcode=1;
                    }*/
                  break;
         case A_MAPINFO:
                  memcpy(&minfo,temp,size);
                  maplen=size / sizeof(TMAP_EDIT_INFO);
                  sect=0;
                  for (i=0;i<maplen;i++) sect+=minfo[i].layer;
                  if (sect/maplen<-20) Shift_map_sectors_up();
                  if (sect/maplen>20)  Shift_map_sectors_down();
                  break;
         case A_MAPMACR:
                  load_macros(temp);
                  break;
         case A_MAPEND:
                  nmapend=0;
                  break;
         case A_MAPITEM:
                  load_item_map(temp,size);
                  break;
         case A_MAPMOBS:
                  load_mob_map(temp,size);
                  break;
         case A_MOBS:
                  load_mobs_to_map(temp,size);
                  mglob.local_monsters=1;
                  break;
         case A_MOBSND:
                  load_sound_dat(temp,size);
                  break;
         case A_MAPVYK:
                  memcpy(vyklenky,temp,size);
                  break;
         case A_PASSW:
/*                  if (passpass<2)
                    {
                    memcpy(password,temp,size);
                    encrypt(password);
                    passpass=2;
                    }*/
                  break;
        }
     else
        {
        if (temp!=NULL)free(temp);
        fclose(f);
        return -1;
        }
     free(temp);
     }
  while (nmapend);
  fclose(f);
  for(r=1;r<maplen;r++)
     for(i=0;i<4;i++)
     if (mapa.sidedef[r][i].flags & 0x40000)
        if ((minfo[r].x+minfo[r].y+i)& 1) mapa.sidedef[r][i].prim-=(mapa.sidedef[r][i].prim_anim & 0xf)+1;
  backup=0;
  if (newcode) Shift_map_sectors_down();
  return 0;
  }
Beispiel #15
0
int GetSummaries(void)
{
  int fd,i,j,n,s_len;
   short end_flag;
   char tmp[EPG_SUMMARY_LEN];
   struct summary * summary;
   epg_summary_t *epgsummary = (epg_summary_t *) buffer;
   epg_replay_t *epg_replay;
   
   fprintf (stderr,"Reading summaries ...\n");
   nb_summaries=0;
   if((fd = open("Summaries",O_RDWR)) < 0)
   {
    perror("Summaries ");
    return -1;
   }
   //   SetFiltSection(fd,211,0x90);

   /* Read Summaries */
   do {
     if (load_section(&s_len,fd)<0) { 
       fprintf (stderr,"Error while reading summaries\n");
       perror("read:");
       return -1;
     }
     fprintf(stderr, "smm len=%d ",buffer[8+3]);
     memcpy(tmp, buffer+18, (int) (buffer[8+3]));
     tmp[buffer[8+3]]='\0';
     fprintf(stderr, "summ=%s\n",tmp);
   }
   while (1);	/* Invalid Data */
#if 0
   memcpy (first_buffer, buffer, EPG_SUMMARY_LEN);	/* Store the first summary */

   end_flag =0;
   while (!end_flag)
   {
      n = read(fd,buffer,MAX_SECTION_BUFFER);
      if (n <= 0)
      {
         perror("Error while reading summaries : ");
         exit(1);
      }
      if (n < 12 || buffer[7] != 0xFF || buffer[8] != 0xFF || buffer[9] !=0xFF || buffer[10] >= 10)	/* Invalid Data */
         continue;
         
      if (!memcmp (first_buffer,buffer,EPG_SUMMARY_LEN))  /* Got all summaries ? */
         end_flag=1;

      buffer[n] = 0;	/* String terminator */

      summary = malloc (sizeof (struct summary));
      summaries[nb_summaries++] = summary;

      summary -> id = HILO32 (epgsummary->program_id);
      /* Index of summary text beginning */
      j = EPG_SUMMARY_LEN + epgsummary->nb_replays*EPG_REPLAY_LEN;
      summary -> text = malloc (n+1 - j);

      if (summary -> text == NULL)
      {
         fprintf (stderr,"Memory allocation error %d\n",n+1-j);
#ifdef DEBUG
         fprintf (stderr,"n=%d j=%d nb_replays=%d\n",n,j,epgsummary->nb_replays);
         for (i=0; i<n; i++)
            fprintf (stderr,"%02X ",buffer[i]);
         fprintf (stderr,"\n%s\n", buffer+10);
#endif
         exit(1);
      }
      /* Copy the summary and replace line feeds by the "|" character */
      i=0;
      do
      {
         summary -> text[i] = buffer[j+i] == '\n' ? '|' : buffer[j+i];
         i++;
      }
      while (buffer[j+i-1] != 0);
      summary -> nb_replays = epgsummary->nb_replays;

      /* Get the times of replays */
      epg_replay = (epg_replay_t *) (epgsummary+1);
      for (i=0; i< summary -> nb_replays; i++)
      {
         summary -> time[i] = MjdToEpochTime(epg_replay->replay_mjd) +
            			BcdTimeToSeconds(epg_replay->replay_time);
//       summary -> time[i] = ProviderLocalTime2UTC (summary -> time[i]);
         summary -> time[i] = LocalTime2UTC (summary -> time[i]);
         summary -> channel_id[i] = epg_replay->channel_id-1;
         summary -> subtitles[i] = epg_replay->subtitles;
         summary -> vm[i] = epg_replay->vm;
         summary -> vo[i] = epg_replay->vo;
         summary -> last_replay[i] = epg_replay->last;
         epg_replay++;
      }
   }
   //   ioctl(fd, DMX_STOP);
#endif
   close (fd);
   return 0;
}
Beispiel #16
0
int GetTitles2(void)
{
  int fd,i, j, pos, nb_showings, s_len, title_len, duration, rank = -1;
  char first_buffer[EPG_TITLE_LEN];
  char tmp[100];
  short end_flag, summ_avail;
  struct program * program;
  epg_title_t *epgtitle = (epg_title_t *) buffer;
  time_t broadcast_time;

  nb_programs=0;
  for (i=0; i<24*7; i++)
    hour_index[i] = -1;

  if((fd = open("Titles",O_RDWR)) < 0) {
    perror("Titles ");
    return -1;
  }
  //   SetFiltSection(fd,210,0x90);
  end_flag = 0;
  while (!end_flag) {
    if (load_section(&s_len, fd)<0) return -1;
    fprintf (stderr,"Parsing titles ...\n");
    
    pos = 0;
    /* We begin a section, first check if it has the                                                
       correct ID */
    if (buffer[pos] != 0x92) {
      fprintf(stderr, "Error: bad table ID (not 0x92)\n");
      return -1;
    } else fprintf(stderr, "New section--------------------------\n");
    /* Skip first bytes */
    pos += 10;
    
    /* Arriving here pos should point to the title length */
    while (pos < s_len-4) {
      /*      fprintf(stderr,">>>>>>> rank = %d >>>>>>>>>>\n",rank);*/
      title_len = buffer[pos];
      pos++;
      memcpy(tmp, buffer+pos, title_len);
      fprintf(stderr,"len = %d <> ", title_len);
      tmp[title_len]='\0';
      i = get_rank(tmp[0]);
      if (rank < 0) rank = i;
      /* If rank < 100 then we still did not encounter the next rank
	 so check if we are there now */
      else if (rank < 100) {
	/* Check if we are still at the same rank as we began with
	   If not store the new rank+100 so we know where to stop */
	if (rank != i) rank = i+100;
      } else if (rank < 200) {
	/* Check if we've browsed the next rank completely */
	if (rank-100 != i) rank += 100;
      } else if (rank-200 == i) {
	/* We have already done the full loop so stop */
		end_flag = 1;
	break;      
      }
      pos += title_len;
      nb_showings = (buffer[pos] & 0x70) >> 4;
      summ_avail = (buffer[pos] & 0x80)!=0;
      duration = (buffer[pos]&0x0F) *256 + buffer[pos+1];
      /* Skip to the first showing */
      pos += 3;
      fprintf(stderr, "%s on channel %d, duration = %d, reruns=%d, summ=%d\n", tmp, buffer[pos], duration, nb_showings, summ_avail);
      /* Skip to next title : we skip 4 bytes * (nb_showings & 0x7F >> 4)
	 4 bytes for each run
      for (j=0; j<nb_showings; j++) {
	int t = (buffer[pos+j*4+1]&0x07)*256+buffer[pos+j*4+2];
	fprintf(stderr, "HH:MM = %d:%d <> Nb of days=%d <> LAST=%d<<>>",
		t / 60+6, t % 60,
		(buffer[pos+4*j+1] & 0xF8) >> 3,
		buffer[pos+4*j+3]);
		}*/
      pos += 4*nb_showings;
      /*      fprintf(stderr, "--- pos=%d, s_len=%d ---", pos,s_len);*/
    }
  }
  fprintf(stderr," Parsing done--------------------\n");
  close (fd);
  return 0;
}