示例#1
0
bool reios_locate_bootfile(const char* bootfile)
{
   u32 data_len = 2048 * 1024;
   u8* temp = new u8[data_len];

   libGDR_ReadSector(temp, base_fad + 16, 1, 2048);

   if (memcmp(temp, "\001CD001\001", 7) == 0) {
      printf("reios: iso9660 PVD found\n");
      u32 lba = read_u32bi(&temp[156 + 2]); //make sure to use big endian
      u32 len = read_u32bi(&temp[156 + 10]); //make sure to use big endian

      data_len = ((len + 2047) / 2048) *2048;

      printf("reios: iso9660 root_directory, FAD: %d, len: %d\n", 150 + lba, data_len);
      libGDR_ReadSector(temp, 150 + lba, data_len/2048, 2048);
   }
   else {
      libGDR_ReadSector(temp, base_fad + 16, data_len / 2048, 2048);
   }

   for (int i = 0; i < (data_len-20); i++)
   {
      if (memcmp(temp+i, bootfile, strlen(bootfile)) == 0)
      {
         printf("Found %s at %06X\n", bootfile, i);

         u32 lba = read_u32bi(&temp[i - 33 +  2]); //make sure to use big endian
         u32 len = read_u32bi(&temp[i - 33 + 10]); //make sure to use big endian

         printf("filename len: %d\n", temp[i - 1]);
         printf("file LBA: %d\n", lba);
         printf("file LEN: %d\n", len);

         if (descrambl)
            descrambl_file(lba + 150, len, GetMemPtr(0x8c010000, 0));
         else
            libGDR_ReadSector(GetMemPtr(0x8c010000, 0), lba + 150, (len + 2047) / 2048, 2048);

#if 0
         if (false)
         {
            FILE* f = fopen("z:\\1stboot.bin", "wb");
            fwrite(GetMemPtr(0x8c010000, 0), 1, len, f);
            fclose(f);
         }
#endif

         delete[] temp;

         bootfile_inited = true;
         return true;
      }
   }

   delete[] temp;
   return false;
}
示例#2
0
const char* reios_locate_ip() {

	if (libGDR_GetDiscType() == GdRom) {
		base_fad = 45150;
		descrambl = false;
	}
	else {
		u8 ses[6];
		libGDR_GetSessionInfo(ses, 0);
		libGDR_GetSessionInfo(ses, ses[2]);
		base_fad = (ses[3] << 16) | (ses[4] << 8) | (ses[5] << 0);
		descrambl = true;
	}

	printf("reios: loading ip.bin from FAD: %d\n", base_fad);

	libGDR_ReadSector(GetMemPtr(0x8c008000, 0), base_fad, 16, 2048);
	
	memset(reios_bootfile, 0, sizeof(reios_bootfile));
	memcpy(reios_bootfile, GetMemPtr(0x8c008060, 0), 16);

	printf("reios: bootfile is '%s'\n", reios_bootfile);

	for (int i = 15; i >= 0; i--) {
		if (reios_bootfile[i] != ' ')
			break;
		reios_bootfile[i] = 0;
	}
	return reios_bootfile;
}
示例#3
0
const char* reios_locate_ip(void)
{
   char ip_bin[256];
   if (libGDR_GetDiscType() == GdRom)
   {
      base_fad = 45150;
      descrambl = false;
   }
   else
   {
      u8 ses[6];
      libGDR_GetSessionInfo(ses, 0);
      libGDR_GetSessionInfo(ses, ses[2]);
      base_fad = (ses[3] << 16) | (ses[4] << 8) | (ses[5] << 0);
      descrambl = true;
   }

   libGDR_ReadSector(GetMemPtr(0x8c008000, 0), base_fad, 256, 2048);

   memset(ip_bin, 0, sizeof(ip_bin));
   memcpy(ip_bin, GetMemPtr(0x8c008000, 0), 256);
   memcpy(&reios_hardware_id[0], &ip_bin[0], 16 * sizeof(char));
   memcpy(&reios_maker_id[0], &ip_bin[16],   16 * sizeof(char));
   memcpy(&reios_device_info[0], &ip_bin[32],   16 * sizeof(char));
   memcpy(&reios_area_symbols[0], &ip_bin[48],   8 * sizeof(char));
   memcpy(&reios_peripherals[0], &ip_bin[56],   8 * sizeof(char));
   memcpy(&reios_product_number[0], &ip_bin[64],   10 * sizeof(char));
   memcpy(&reios_product_version[0], &ip_bin[74],   6 * sizeof(char));
   memcpy(&reios_releasedate[0], &ip_bin[80],   16 * sizeof(char));
   memcpy(&reios_boot_filename[0], &ip_bin[96],   16 * sizeof(char));
   memcpy(&reios_software_company[0], &ip_bin[112],   16 * sizeof(char));
   memcpy(&reios_software_name[0], &ip_bin[128],   128 * sizeof(char));

   printf("reios: IP.bin is '%s'\n", ip_bin);
   printf("reios: Hardware ID is: %s\n", reios_hardware_id);
   printf("reios: Maker ID is:    %s\n",    reios_maker_id);
   printf("reios: Device info is: %s\n",    reios_device_info);
   printf("reios: Area symbols is: %s\n",    reios_area_symbols);
   printf("reios: Peripherals is: %s\n",    reios_peripherals);
   printf("reios: Product number is: %s\n",    reios_product_number);
   printf("reios: Product version is: %s\n",    reios_product_version);
   printf("reios: Release date is: %s\n",    reios_releasedate);
   printf("reios: Boot filename is: %s\n",    reios_boot_filename);
   printf("reios: Software company is: %s\n",    reios_software_company);
   printf("reios: Software name is: %s\n",    reios_software_name);

   printf("reios: loading ip.bin from FAD: %d\n", base_fad);

   libGDR_ReadSector(GetMemPtr(0x8c008000, 0), base_fad, 16, 2048);

   memset(reios_bootfile, 0, sizeof(reios_bootfile));
   memcpy(reios_bootfile, GetMemPtr(0x8c008060, 0), 16);

   printf("reios: bootfile is '%s'\n", reios_bootfile);

   for (int i = 15; i >= 0; i--)
   {
      if (reios_bootfile[i] != ' ')
         break;
      reios_bootfile[i] = 0;
   }
   return reios_bootfile;
}