diff --git a/include/arm9/nandimage.h b/include/arm9/nandimage.h deleted file mode 100644 index 425f685..0000000 --- a/include/arm9/nandimage.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -/* - * This file is part of fastboot 3DS - * Copyright (C) 2017 derrek, profi200 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "types.h" -#include "arm9/ncsd.h" -#include "fatfs/ff.h" - - -#define NANDIMG_ERROR_BADPATH -1 -#define NANDIMG_ERROR_NEXISTS -2 -#define NANDIMG_ERROR_NCONTS -3 - - - -int validateNandImage(const char *filePath); -bool isNandImageCompatible(FIL *file); diff --git a/source/arm9/nandimage.c b/source/arm9/nandimage.c deleted file mode 100644 index b8f1545..0000000 --- a/source/arm9/nandimage.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is part of fastboot 3DS - * Copyright (C) 2017 derrek, profi200 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include "arm9/dev.h" -#include "arm9/nandimage.h" -#include "util.h" - - - -int validateNandImage(const char *filePath) -{ - FIL file; - bool isContinuous; - - // only nand images on SD card are allowed. - if(strncmp(filePath, "sdmc:", 5) != 0) - return NANDIMG_ERROR_BADPATH; - - if(f_open(&file, filePath, FA_READ) != FR_OK) - return NANDIMG_ERROR_NEXISTS; - - isContinuous = (file.obj.stat & 3) == 2; - - f_close(&file); - - if(!isContinuous) - return NANDIMG_ERROR_NCONTS; - - return 0; -} - -bool isNandImageCompatible(FIL *file) -{ - NCSD_header imageHeader; - NCSD_header nandHeader; - size_t bytesRead; - - FSIZE_t offset = f_tell(file); - - if(f_lseek(file, 0) != FR_OK) - { - return false; - } - - if(f_read(file, &imageHeader, sizeof(NCSD_header), &bytesRead) != FR_OK - || bytesRead != sizeof(NCSD_header)) - { - return false; - } - - // restore original rw pointer - if(f_lseek(file, offset) != FR_OK) - { - return false; - } - - if(!dev_rawnand->read_sector(0, 1, &nandHeader)) - { - return false; - } - - /* compare everything except the signature */ - return memcmp(&imageHeader.magic, &nandHeader.magic, 0x100) == 0; -}