mirror of
https://github.com/wiiu-env/wiiu-nanddumper-payload.git
synced 2024-11-22 03:19:17 +01:00
Fixed some tab/spaces confusion
This commit is contained in:
parent
1d7fb42aa3
commit
7513886800
@ -154,14 +154,14 @@ int slcWrite2_patch(void *physical_device_info, u32 offset_high, u32 offset_low,
|
||||
|
||||
int eccCheck_patch(void *buffer, char* spare_ecc, char* calculated_ecc, int ecc_length)
|
||||
{
|
||||
if (io_buffer_spare_status || io_buffer_spare_pos > sizeof(io_buffer_spare) || io_buffer_spare_pos+0x840 > sizeof(io_buffer_spare)) {
|
||||
io_buffer_spare_status = -1;
|
||||
return 0;
|
||||
}
|
||||
memcpy(io_buffer_spare+io_buffer_spare_pos, buffer, 0x800);
|
||||
io_buffer_spare_pos += 0x800;
|
||||
memcpy(io_buffer_spare+io_buffer_spare_pos, spare_ecc - 0x30, 0x40);
|
||||
io_buffer_spare_pos += 0x40;
|
||||
if (io_buffer_spare_status || io_buffer_spare_pos > sizeof(io_buffer_spare) || io_buffer_spare_pos+0x840 > sizeof(io_buffer_spare)) {
|
||||
io_buffer_spare_status = -1;
|
||||
return 0;
|
||||
}
|
||||
memcpy(io_buffer_spare+io_buffer_spare_pos, buffer, 0x800);
|
||||
io_buffer_spare_pos += 0x800;
|
||||
memcpy(io_buffer_spare+io_buffer_spare_pos, spare_ecc - 0x30, 0x40);
|
||||
io_buffer_spare_pos += 0x40;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ static int srcRead(void* deviceHandle, void *data_ptr, u32 offset, u32 sectors,
|
||||
|
||||
int slc_dump(void *deviceHandle, const char* device, const char* filename, int y_offset)
|
||||
{
|
||||
//also create a mutex for synchronization with end of operation...
|
||||
//also create a mutex for synchronization with end of operation...
|
||||
int sync_mutex = FS_SVC_CREATEMUTEX(1, 1);
|
||||
FS_SVC_ACQUIREMUTEX(sync_mutex, 0);
|
||||
|
||||
@ -59,76 +59,76 @@ int slc_dump(void *deviceHandle, const char* device, const char* filename, int y
|
||||
FS_SLEEP(1000);
|
||||
|
||||
FL_FILE *file = fl_fopen(filename, "w");
|
||||
if (!file) {
|
||||
if (!file) {
|
||||
_printf(20, y_offset, "Failed to open %s for writing", filename);
|
||||
goto error;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
_printf(20, y_offset, "%s = %05X / 40000", device, offset);
|
||||
_printf(20, y_offset, "%s = %05X / 40000", device, offset);
|
||||
|
||||
//! set flash erased byte to buffer
|
||||
FS_MEMSET(io_buffer_spare, 0xff, IO_BUFFER_SPARE_SIZE);
|
||||
io_buffer_spare_status = 0;
|
||||
io_buffer_spare_pos = 0;
|
||||
io_buffer_spare_status = 0;
|
||||
io_buffer_spare_pos = 0;
|
||||
//readResult = readSlc(io_buffer, offset, (sizeof(io_buffer) / SLC_BYTES_PER_SECTOR), deviceHandle);
|
||||
readResult = srcRead(deviceHandle, io_buffer, offset, readSize, result_array);
|
||||
|
||||
if (readResult || io_buffer_spare_status || io_buffer_spare_pos != IO_BUFFER_SPARE_SIZE) {
|
||||
|
||||
_printf(20, y_offset+10, "Failed to read flash block. read result: 0x%08X spare status: 0x%08X spare pos: 0x%08X", readResult, io_buffer_spare_status, io_buffer_spare_pos);
|
||||
goto error;
|
||||
}
|
||||
//FS_SLEEP(10);
|
||||
writeResult = fl_fwrite(io_buffer_spare, 1, readSize * SLC_BYTES_PER_SECTOR, file);
|
||||
if (writeResult != readSize * SLC_BYTES_PER_SECTOR) {
|
||||
_printf(20, y_offset + 10, "%s: Failed to write %d bytes to file %s (result: %d)!", device, readSize * SLC_BYTES_PER_SECTOR, file, filename, writeResult);
|
||||
goto error;
|
||||
}
|
||||
offset += readSize;
|
||||
if (readResult || io_buffer_spare_status || io_buffer_spare_pos != IO_BUFFER_SPARE_SIZE) {
|
||||
|
||||
_printf(20, y_offset+10, "Failed to read flash block. read result: 0x%08X spare status: 0x%08X spare pos: 0x%08X", readResult, io_buffer_spare_status, io_buffer_spare_pos);
|
||||
goto error;
|
||||
}
|
||||
//FS_SLEEP(10);
|
||||
writeResult = fl_fwrite(io_buffer_spare, 1, readSize * SLC_BYTES_PER_SECTOR, file);
|
||||
if (writeResult != readSize * SLC_BYTES_PER_SECTOR) {
|
||||
_printf(20, y_offset + 10, "%s: Failed to write %d bytes to file %s (result: %d)!", device, readSize * SLC_BYTES_PER_SECTOR, file, filename, writeResult);
|
||||
goto error;
|
||||
}
|
||||
offset += readSize;
|
||||
}
|
||||
while (offset < SLC_SECTOR_COUNT);
|
||||
|
||||
result = 0;
|
||||
result = 0;
|
||||
|
||||
error:
|
||||
FS_SVC_DESTROYMUTEX(sync_mutex);
|
||||
|
||||
if (file) {
|
||||
fl_fclose(file);
|
||||
}
|
||||
if (file) {
|
||||
fl_fclose(file);
|
||||
}
|
||||
// last print to show "done"
|
||||
_printf(20, y_offset, "%s = %05X / 40000", device, offset);
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
int mlc_dump(u32 mlc_end, int y_offset)
|
||||
{
|
||||
u32 offset = 0;
|
||||
|
||||
int result = -1;
|
||||
int result = -1;
|
||||
int retry = 0;
|
||||
int mlc_result = 0;
|
||||
int callback_result = 0;
|
||||
int write_result = 0;
|
||||
int print_counter = 0;
|
||||
int current_file_index = 0;
|
||||
int current_file_index = 0;
|
||||
|
||||
|
||||
char filename[40];
|
||||
char filename[40];
|
||||
FL_FILE *file = NULL;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
if (!file) {
|
||||
FS_SNPRINTF(filename, sizeof(filename), "/mlc.bin.part%02d", ++current_file_index);
|
||||
file = fl_fopen(filename, "w");
|
||||
if (!file) {
|
||||
_printf(20, y_offset, "Failed to open %s for writing", filename);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (!file) {
|
||||
FS_SNPRINTF(filename, sizeof(filename), "/mlc.bin.part%02d", ++current_file_index);
|
||||
file = fl_fopen(filename, "w");
|
||||
if (!file) {
|
||||
_printf(20, y_offset, "Failed to open %s for writing", filename);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
//! print only every 4th time
|
||||
if(print_counter == 0)
|
||||
{
|
||||
@ -158,30 +158,30 @@ int mlc_dump(u32 mlc_end, int y_offset)
|
||||
}
|
||||
else
|
||||
{
|
||||
write_result = fl_fwrite(io_buffer, 1, IO_BUFFER_SIZE, file);
|
||||
if (write_result != IO_BUFFER_SIZE) {
|
||||
_printf(20, y_offset + 10, "mlc: Failed to write %d bytes to file %s (result: %d)!", IO_BUFFER_SIZE, file, filename, write_result);
|
||||
goto error;
|
||||
}
|
||||
offset += (IO_BUFFER_SIZE / MLC_BYTES_PER_SECTOR);
|
||||
if ((offset % 0x400000) == 0) {
|
||||
fl_fclose(file);
|
||||
file = NULL;
|
||||
}
|
||||
write_result = fl_fwrite(io_buffer, 1, IO_BUFFER_SIZE, file);
|
||||
if (write_result != IO_BUFFER_SIZE) {
|
||||
_printf(20, y_offset + 10, "mlc: Failed to write %d bytes to file %s (result: %d)!", IO_BUFFER_SIZE, file, filename, write_result);
|
||||
goto error;
|
||||
}
|
||||
offset += (IO_BUFFER_SIZE / MLC_BYTES_PER_SECTOR);
|
||||
if ((offset % 0x400000) == 0) {
|
||||
fl_fclose(file);
|
||||
file = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(offset < mlc_end); //! TODO: make define MLC32_SECTOR_COUNT:
|
||||
|
||||
result = 0;
|
||||
result = 0;
|
||||
|
||||
error:
|
||||
if (file) {
|
||||
fl_fclose(file);
|
||||
}
|
||||
if (file) {
|
||||
fl_fclose(file);
|
||||
}
|
||||
// last print to show "done"
|
||||
_printf(20, y_offset, "mlc = %08X / %08X, mlc res %08X, retry %d", offset, mlc_end, mlc_result, retry);
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
int check_nand_type(void)
|
||||
@ -227,31 +227,31 @@ int check_nand_type(void)
|
||||
|
||||
void dump_nand_complete()
|
||||
{
|
||||
int offset_y = 30;
|
||||
int offset_y = 30;
|
||||
_printf(20, offset_y, "Init SD card....");
|
||||
if ( InitSDCardFAT32() != 0 ) {
|
||||
if ( InitSDCardFAT32() != 0 ) {
|
||||
FS_SLEEP(3000);
|
||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||
}
|
||||
}
|
||||
_printf(20, offset_y, "Init SD card.... Success!");
|
||||
offset_y += 10;
|
||||
offset_y += 10;
|
||||
|
||||
//wait_format_confirmation();
|
||||
|
||||
u32 mlc_sector_count = 0;
|
||||
if (dumper_config.dump_mlc) {
|
||||
mlc_init();
|
||||
FS_SLEEP(1000);
|
||||
u32 mlc_sector_count = 0;
|
||||
if (dumper_config.dump_mlc) {
|
||||
mlc_init();
|
||||
FS_SLEEP(1000);
|
||||
|
||||
int nand_type = check_nand_type();
|
||||
//u32 sdio_sector_count = FS_MMC_SDCARD_STRUCT[0x30/4];
|
||||
mlc_sector_count = FS_MMC_MLC_STRUCT[0x30/4];
|
||||
//u32 fat32_partition_offset = (MLC_BASE_SECTORS + mlc_sector_count);
|
||||
int nand_type = check_nand_type();
|
||||
//u32 sdio_sector_count = FS_MMC_SDCARD_STRUCT[0x30/4];
|
||||
mlc_sector_count = FS_MMC_MLC_STRUCT[0x30/4];
|
||||
//u32 fat32_partition_offset = (MLC_BASE_SECTORS + mlc_sector_count);
|
||||
|
||||
_printf(20, offset_y, "Detected %d GB MLC NAND type.", (nand_type == MLC_NAND_TYPE_8GB) ? 8 : 32);
|
||||
offset_y += 10;
|
||||
}
|
||||
offset_y += 10;
|
||||
_printf(20, offset_y, "Detected %d GB MLC NAND type.", (nand_type == MLC_NAND_TYPE_8GB) ? 8 : 32);
|
||||
offset_y += 10;
|
||||
}
|
||||
offset_y += 10;
|
||||
|
||||
/*if(sdio_sector_count < fat32_partition_offset)
|
||||
{
|
||||
@ -266,58 +266,58 @@ void dump_nand_complete()
|
||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||
}*/
|
||||
|
||||
if (dumper_config.dump_otp) {
|
||||
_printf(20, offset_y, "Writing otp...");
|
||||
FL_FILE *file = fl_fopen("/otp.bin", "w");
|
||||
if (!file) {
|
||||
_printf(20, offset_y+10, "Failed to open /otp.bin for writing!");
|
||||
goto error;
|
||||
}
|
||||
// It doesn't work if we try write directly this buffer, does it try to access too much?
|
||||
memcpy(io_buffer, dumper_config.otp_buffer, sizeof(dumper_config.otp_buffer));
|
||||
if (fl_fwrite(io_buffer, 1, sizeof(dumper_config.otp_buffer), file) != sizeof(dumper_config.otp_buffer)) {
|
||||
fl_fclose(file);
|
||||
_printf(20, offset_y+10, "Failed to write otp to file!");
|
||||
goto error;
|
||||
}
|
||||
fl_fclose(file);
|
||||
_printf(20, offset_y, "Writing otp... Success!");
|
||||
offset_y += 10;
|
||||
}
|
||||
if (dumper_config.dump_seeprom) {
|
||||
_printf(20, offset_y, "Writing seeprom...");
|
||||
FL_FILE *file = fl_fopen("/seeprom.bin", "w");
|
||||
if (!file) {
|
||||
_printf(20, offset_y+10, "Failed to open /seeprom.bin for writing!");
|
||||
goto error;
|
||||
}
|
||||
// It doesn't work if we try write directly this buffer, does it try to access too much?
|
||||
memcpy(io_buffer, dumper_config.seeprom_buffer, sizeof(dumper_config.seeprom_buffer));
|
||||
if (fl_fwrite(io_buffer, 1, sizeof(dumper_config.seeprom_buffer), file) != sizeof(dumper_config.seeprom_buffer)) {
|
||||
fl_fclose(file);
|
||||
_printf(20, offset_y+10, "Failed to write seeprom to file!");
|
||||
goto error;
|
||||
}
|
||||
fl_fclose(file);
|
||||
_printf(20, offset_y, "Writing seeprom... Success!");
|
||||
offset_y += 10;
|
||||
}
|
||||
if (dumper_config.dump_slc) {
|
||||
if (slc_dump(FS_SLC_PHYS_DEV_STRUCT, "slc ", "/slc.bin", offset_y))
|
||||
goto error;
|
||||
offset_y += 10;
|
||||
}
|
||||
if (dumper_config.dump_slccmpt) {
|
||||
if (slc_dump(FS_SLCCMPT_PHYS_DEV_STRUCT, "slccmpt", "/slccmpt.bin", offset_y))
|
||||
goto error;
|
||||
offset_y += 10;
|
||||
}
|
||||
if (dumper_config.dump_mlc) {
|
||||
if (mlc_dump(mlc_sector_count, offset_y))
|
||||
goto error;
|
||||
offset_y += 10;
|
||||
}
|
||||
offset_y += 20;
|
||||
if (dumper_config.dump_otp) {
|
||||
_printf(20, offset_y, "Writing otp...");
|
||||
FL_FILE *file = fl_fopen("/otp.bin", "w");
|
||||
if (!file) {
|
||||
_printf(20, offset_y+10, "Failed to open /otp.bin for writing!");
|
||||
goto error;
|
||||
}
|
||||
// It doesn't work if we try write directly this buffer, does it try to access too much?
|
||||
memcpy(io_buffer, dumper_config.otp_buffer, sizeof(dumper_config.otp_buffer));
|
||||
if (fl_fwrite(io_buffer, 1, sizeof(dumper_config.otp_buffer), file) != sizeof(dumper_config.otp_buffer)) {
|
||||
fl_fclose(file);
|
||||
_printf(20, offset_y+10, "Failed to write otp to file!");
|
||||
goto error;
|
||||
}
|
||||
fl_fclose(file);
|
||||
_printf(20, offset_y, "Writing otp... Success!");
|
||||
offset_y += 10;
|
||||
}
|
||||
if (dumper_config.dump_seeprom) {
|
||||
_printf(20, offset_y, "Writing seeprom...");
|
||||
FL_FILE *file = fl_fopen("/seeprom.bin", "w");
|
||||
if (!file) {
|
||||
_printf(20, offset_y+10, "Failed to open /seeprom.bin for writing!");
|
||||
goto error;
|
||||
}
|
||||
// It doesn't work if we try write directly this buffer, does it try to access too much?
|
||||
memcpy(io_buffer, dumper_config.seeprom_buffer, sizeof(dumper_config.seeprom_buffer));
|
||||
if (fl_fwrite(io_buffer, 1, sizeof(dumper_config.seeprom_buffer), file) != sizeof(dumper_config.seeprom_buffer)) {
|
||||
fl_fclose(file);
|
||||
_printf(20, offset_y+10, "Failed to write seeprom to file!");
|
||||
goto error;
|
||||
}
|
||||
fl_fclose(file);
|
||||
_printf(20, offset_y, "Writing seeprom... Success!");
|
||||
offset_y += 10;
|
||||
}
|
||||
if (dumper_config.dump_slc) {
|
||||
if (slc_dump(FS_SLC_PHYS_DEV_STRUCT, "slc ", "/slc.bin", offset_y))
|
||||
goto error;
|
||||
offset_y += 10;
|
||||
}
|
||||
if (dumper_config.dump_slccmpt) {
|
||||
if (slc_dump(FS_SLCCMPT_PHYS_DEV_STRUCT, "slccmpt", "/slccmpt.bin", offset_y))
|
||||
goto error;
|
||||
offset_y += 10;
|
||||
}
|
||||
if (dumper_config.dump_mlc) {
|
||||
if (mlc_dump(mlc_sector_count, offset_y))
|
||||
goto error;
|
||||
offset_y += 10;
|
||||
}
|
||||
offset_y += 20;
|
||||
|
||||
_printf(20, offset_y, "Complete! -> rebooting into sysNAND...");
|
||||
|
||||
@ -325,7 +325,7 @@ void dump_nand_complete()
|
||||
svcShutdown(SHUTDOWN_TYPE_REBOOT);
|
||||
|
||||
error:
|
||||
offset_y += 20;
|
||||
offset_y += 20;
|
||||
_printf(20, offset_y, "Error! -> rebooting into sysNAND...");
|
||||
|
||||
FS_SLEEP(3000);
|
||||
|
@ -630,12 +630,12 @@ static uint32 _read_sectors(FL_FILE* file, uint32 offset, uint8 *buffer, uint32
|
||||
void fl_init(void)
|
||||
{
|
||||
int i;
|
||||
memset(_files, 0, sizeof(_files));
|
||||
memset(&_filelib_init, 0, sizeof(_filelib_init));
|
||||
memset(&_filelib_valid, 0, sizeof(_filelib_valid));
|
||||
memset(&_fs, 0, sizeof(_fs));
|
||||
memset(&_open_file_list, 0, sizeof(_open_file_list));
|
||||
memset(&_free_file_list, 0, sizeof(_free_file_list));
|
||||
memset(_files, 0, sizeof(_files));
|
||||
memset(&_filelib_init, 0, sizeof(_filelib_init));
|
||||
memset(&_filelib_valid, 0, sizeof(_filelib_valid));
|
||||
memset(&_fs, 0, sizeof(_fs));
|
||||
memset(&_open_file_list, 0, sizeof(_open_file_list));
|
||||
memset(&_free_file_list, 0, sizeof(_free_file_list));
|
||||
|
||||
fat_list_init(&_free_file_list);
|
||||
fat_list_init(&_open_file_list);
|
||||
|
@ -337,7 +337,7 @@ int fatfs_find_blank_cluster(struct fatfs *fs, uint32 start_cluster, uint32 *fre
|
||||
while (nextcluster != 0x0);
|
||||
|
||||
// Found blank entry
|
||||
fs->last_free_cluster = current_cluster + 1;
|
||||
fs->last_free_cluster = current_cluster + 1;
|
||||
*free_cluster = current_cluster;
|
||||
return 1;
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ void createDevThread_entry(int initialization_type)
|
||||
{
|
||||
//if(check_nand_dump() == 0)
|
||||
//{
|
||||
clearScreen(0x000000FF);
|
||||
_printf(20, 20, "welcome to NAND dumper!");
|
||||
clearScreen(0x000000FF);
|
||||
_printf(20, 20, "welcome to NAND dumper!");
|
||||
|
||||
dump_nand_complete();
|
||||
dump_nand_complete();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -9,86 +9,86 @@
|
||||
unsigned char sd_io_buffer[0x40000] __attribute__((aligned(0x40))) __attribute__((section(".io_buffer")));
|
||||
unsigned int fat_sector = 0;
|
||||
|
||||
#define PARTITION_TYPE_FAT32 0x0c
|
||||
#define PARTITION_TYPE_FAT32_CHS 0x0b
|
||||
#define PARTITION_TYPE_FAT32 0x0c
|
||||
#define PARTITION_TYPE_FAT32_CHS 0x0b
|
||||
|
||||
#define MBR_SIGNATURE 0x55AA
|
||||
#define EBR_SIGNATURE MBR_SIGNATURE
|
||||
#define MBR_SIGNATURE 0x55AA
|
||||
#define EBR_SIGNATURE MBR_SIGNATURE
|
||||
|
||||
#define PARTITION_BOOTABLE 0x80 /* Bootable (active) */
|
||||
#define PARTITION_NONBOOTABLE 0x00 /* Non-bootable */
|
||||
#define PARTITION_TYPE_GPT 0xEE /* Indicates that a GPT header is available */
|
||||
#define PARTITION_BOOTABLE 0x80 /* Bootable (active) */
|
||||
#define PARTITION_NONBOOTABLE 0x00 /* Non-bootable */
|
||||
#define PARTITION_TYPE_GPT 0xEE /* Indicates that a GPT header is available */
|
||||
|
||||
typedef struct _PARTITION_RECORD {
|
||||
u8 status; /* Partition status; see above */
|
||||
u8 chs_start[3]; /* Cylinder-head-sector address to first block of partition */
|
||||
u8 type; /* Partition type; see above */
|
||||
u8 chs_end[3]; /* Cylinder-head-sector address to last block of partition */
|
||||
u32 lba_start; /* Local block address to first sector of partition */
|
||||
u32 block_count; /* Number of blocks in partition */
|
||||
u8 status; /* Partition status; see above */
|
||||
u8 chs_start[3]; /* Cylinder-head-sector address to first block of partition */
|
||||
u8 type; /* Partition type; see above */
|
||||
u8 chs_end[3]; /* Cylinder-head-sector address to last block of partition */
|
||||
u32 lba_start; /* Local block address to first sector of partition */
|
||||
u32 block_count; /* Number of blocks in partition */
|
||||
} __attribute__((__packed__)) PARTITION_RECORD;
|
||||
|
||||
|
||||
typedef struct _MASTER_BOOT_RECORD {
|
||||
u8 code_area[446]; /* Code area; normally empty */
|
||||
PARTITION_RECORD partitions[4]; /* 4 primary partitions */
|
||||
u16 signature; /* MBR signature; 0xAA55 */
|
||||
u8 code_area[446]; /* Code area; normally empty */
|
||||
PARTITION_RECORD partitions[4]; /* 4 primary partitions */
|
||||
u16 signature; /* MBR signature; 0xAA55 */
|
||||
} __attribute__((__packed__)) MASTER_BOOT_RECORD;
|
||||
|
||||
int sd_fat_read(unsigned long sector, unsigned char *buffer, unsigned long sector_count)
|
||||
{
|
||||
// It seems that sdcard_readwrite overwrite more bytes than requested with 0xff.... So I use io_buffer to read it.
|
||||
if (sector_count * SDIO_BYTES_PER_SECTOR > sizeof(sd_io_buffer)) return 0;
|
||||
int result = sdcard_readwrite(SDIO_READ, sd_io_buffer, sector_count, SDIO_BYTES_PER_SECTOR, fat_sector + sector, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||
if (result) return 0;
|
||||
memcpy(buffer, sd_io_buffer, sector_count * SDIO_BYTES_PER_SECTOR);
|
||||
return 1;
|
||||
// It seems that sdcard_readwrite overwrite more bytes than requested with 0xff.... So I use io_buffer to read it.
|
||||
if (sector_count * SDIO_BYTES_PER_SECTOR > sizeof(sd_io_buffer)) return 0;
|
||||
int result = sdcard_readwrite(SDIO_READ, sd_io_buffer, sector_count, SDIO_BYTES_PER_SECTOR, fat_sector + sector, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||
if (result) return 0;
|
||||
memcpy(buffer, sd_io_buffer, sector_count * SDIO_BYTES_PER_SECTOR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sd_fat_write(unsigned long sector, unsigned char *buffer, unsigned long sector_count)
|
||||
{
|
||||
if (sector_count * SDIO_BYTES_PER_SECTOR > sizeof(sd_io_buffer)) return 0;
|
||||
int result = sdcard_readwrite(SDIO_WRITE, buffer, sector_count, SDIO_BYTES_PER_SECTOR, fat_sector + sector, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||
return result ? 0 : 1;
|
||||
if (sector_count * SDIO_BYTES_PER_SECTOR > sizeof(sd_io_buffer)) return 0;
|
||||
int result = sdcard_readwrite(SDIO_WRITE, buffer, sector_count, SDIO_BYTES_PER_SECTOR, fat_sector + sector, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||
return result ? 0 : 1;
|
||||
}
|
||||
|
||||
int InitSDCardFAT32()
|
||||
{
|
||||
MASTER_BOOT_RECORD *mbr = (MASTER_BOOT_RECORD*)sd_io_buffer;
|
||||
memset(mbr, 0, SDIO_BYTES_PER_SECTOR);
|
||||
MASTER_BOOT_RECORD *mbr = (MASTER_BOOT_RECORD*)sd_io_buffer;
|
||||
memset(mbr, 0, SDIO_BYTES_PER_SECTOR);
|
||||
|
||||
int result = sdcard_readwrite(SDIO_READ, mbr, 1, SDIO_BYTES_PER_SECTOR, 0, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||
if(result != 0)
|
||||
{
|
||||
_printf(20, 40, "SD card read failed %i", result);
|
||||
return result;
|
||||
}
|
||||
int result = sdcard_readwrite(SDIO_READ, mbr, 1, SDIO_BYTES_PER_SECTOR, 0, NULL, DEVICE_ID_SDCARD_PATCHED);
|
||||
if(result != 0)
|
||||
{
|
||||
_printf(20, 40, "SD card read failed %i", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (mbr->signature != MBR_SIGNATURE) {
|
||||
_printf(20, 40, "SD not MBR");
|
||||
return -1;
|
||||
}
|
||||
if (mbr->signature != MBR_SIGNATURE) {
|
||||
_printf(20, 40, "SD not MBR");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mbr->partitions[0].status != PARTITION_BOOTABLE && mbr->partitions[0].status != PARTITION_NONBOOTABLE) {
|
||||
_printf(20, 40, "Invalid paritition status");
|
||||
return -1;
|
||||
}
|
||||
if (mbr->partitions[0].status != PARTITION_BOOTABLE && mbr->partitions[0].status != PARTITION_NONBOOTABLE) {
|
||||
_printf(20, 40, "Invalid paritition status");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mbr->partitions[0].type != PARTITION_TYPE_FAT32 && mbr->partitions[0].type != PARTITION_TYPE_FAT32_CHS) {
|
||||
_printf(20, 40, "First paritition not FAT32");
|
||||
return -1;
|
||||
}
|
||||
if (mbr->partitions[0].type != PARTITION_TYPE_FAT32 && mbr->partitions[0].type != PARTITION_TYPE_FAT32_CHS) {
|
||||
_printf(20, 40, "First paritition not FAT32");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fat_sector = le32(mbr->partitions[0].lba_start);
|
||||
|
||||
fl_init();
|
||||
fat_sector = le32(mbr->partitions[0].lba_start);
|
||||
|
||||
fl_init();
|
||||
|
||||
result = fl_attach_media(sd_fat_read, sd_fat_write);
|
||||
if (result != FAT_INIT_OK)
|
||||
{
|
||||
_printf(20, 40, "FAT32 attach failed %i", result);
|
||||
return result;
|
||||
}
|
||||
result = fl_attach_media(sd_fat_read, sd_fat_write);
|
||||
if (result != FAT_INIT_OK)
|
||||
{
|
||||
_printf(20, 40, "FAT32 attach failed %i", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ u32 fs_get_phys_code_base(void)
|
||||
|
||||
void fs_run_patches(u32 ios_elf_start)
|
||||
{
|
||||
fs_config config;
|
||||
fs_config config;
|
||||
|
||||
// write wupserver code and bss
|
||||
section_write(ios_elf_start, _text_start, (void*)fs_get_phys_code_base(), _text_end - _text_start);
|
||||
@ -85,15 +85,15 @@ void fs_run_patches(u32 ios_elf_start)
|
||||
|
||||
section_write_word(ios_elf_start, FS_SLC_ECC_CHECK, ARM_B(FS_SLC_ECC_CHECK, eccCheck_patch));
|
||||
|
||||
config.dump_slc = cfw_config.dumpSlc;
|
||||
config.dump_slccmpt = cfw_config.dumpSlccmpt;
|
||||
config.dump_mlc = cfw_config.dumpMlc;
|
||||
config.dump_otp = cfw_config.dumpOtp;
|
||||
config.dump_seeprom = cfw_config.dumpSeeprom;
|
||||
if (cfw_config.dumpOtp)
|
||||
kernel_memcpy(config.otp_buffer, otp_buffer, sizeof(config.otp_buffer));
|
||||
if (cfw_config.dumpSeeprom)
|
||||
kernel_memcpy(config.seeprom_buffer, seeprom_buffer, sizeof(config.seeprom_buffer));
|
||||
config.dump_slc = cfw_config.dumpSlc;
|
||||
config.dump_slccmpt = cfw_config.dumpSlccmpt;
|
||||
config.dump_mlc = cfw_config.dumpMlc;
|
||||
config.dump_otp = cfw_config.dumpOtp;
|
||||
config.dump_seeprom = cfw_config.dumpSeeprom;
|
||||
if (cfw_config.dumpOtp)
|
||||
kernel_memcpy(config.otp_buffer, otp_buffer, sizeof(config.otp_buffer));
|
||||
if (cfw_config.dumpSeeprom)
|
||||
kernel_memcpy(config.seeprom_buffer, seeprom_buffer, sizeof(config.seeprom_buffer));
|
||||
section_write(ios_elf_start, dumper_config, &config, sizeof(config));
|
||||
|
||||
//section_write_word(ios_elf_start, FS_USB_READ, ARM_B(FS_USB_READ, usbRead_patch));
|
||||
|
@ -326,9 +326,9 @@ static void uhs_exploit_init(int dev_uhs_0_handle, cfw_config_t * config)
|
||||
|
||||
//if(config->redNAND)
|
||||
//{
|
||||
payloads->size = sizeof(ios_fs_bin);
|
||||
memcpy(payloads->data, ios_fs_bin, payloads->size);
|
||||
payloads = (payload_info_t*)( ((char*)payloads) + ALIGN4(sizeof(payload_info_t) + payloads->size) );
|
||||
payloads->size = sizeof(ios_fs_bin);
|
||||
memcpy(payloads->data, ios_fs_bin, payloads->size);
|
||||
payloads = (payload_info_t*)( ((char*)payloads) + ALIGN4(sizeof(payload_info_t) + payloads->size) );
|
||||
|
||||
// if(config->seeprom_red)
|
||||
// {
|
||||
|
12
src/main.c
12
src/main.c
@ -25,9 +25,9 @@ static int exitToHBLOnLaunch = 0;
|
||||
|
||||
int Menu_Main(void)
|
||||
{
|
||||
//!---------INIT---------
|
||||
InitOSFunctionPointers();
|
||||
InitSysFunctionPointers();
|
||||
//!---------INIT---------
|
||||
InitOSFunctionPointers();
|
||||
InitSysFunctionPointers();
|
||||
InitFSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
@ -83,9 +83,9 @@ int Menu_Main(void)
|
||||
{
|
||||
//if(config.noIosReload == 0)
|
||||
//{
|
||||
OSForceFullRelaunch();
|
||||
SYSLaunchMenu();
|
||||
returnCode = EXIT_RELAUNCH_ON_LOAD;
|
||||
OSForceFullRelaunch();
|
||||
SYSLaunchMenu();
|
||||
returnCode = EXIT_RELAUNCH_ON_LOAD;
|
||||
//}
|
||||
//else if(config.launchSysMenu)
|
||||
//{
|
||||
|
Loading…
Reference in New Issue
Block a user