示例#1
0
文件: firm.c 项目: izzy420/ReiNand
//Nand redirection
void loadEmu(void){ 
    //Dont boot emu if AGB game was just played, or if START was held.
    if((HID & 0xFFF) == (1 << 3) || CFG_BOOTENV == 0x7) return;
    
    //Read emunand code from SD
    fopen("/rei/emunand/emunand.bin");
    Size emuSize = fsize();
    getEmuCode(firmLocation, firmSize, &emuCodeOffset);
    fread(emuCodeOffset, 1, emuSize);
    fclose();
    
    //Setup Emunand code
    uPtr *pos_sdmmc = memsearch(emuCodeOffset, "SDMC", emuSize, 4);
    uPtr *pos_offset = memsearch(emuCodeOffset, "NAND", emuSize, 4);
    uPtr *pos_header = memsearch(emuCodeOffset, "NCSD", emuSize, 4);
	getSDMMC(firmLocation, firmSize, &sdmmcOffset);
    getEmuRW(firmLocation, firmSize, &emuRead, &emuWrite);
    *pos_sdmmc = sdmmcOffset;
    *pos_offset = emuOffset;
    *pos_header = emuHeader;
    
    //Add Emunand hooks
    memcpy((u8*)emuRead, nandRedir, sizeof(nandRedir));
    memcpy((u8*)emuWrite, nandRedir, sizeof(nandRedir));

    //Set MPU for emu code region
    getMPU(firmLocation, firmSize, &mpuOffset);
    memcpy((u8*)mpuOffset, mpu, sizeof(mpu));
}
示例#2
0
文件: firm.c 项目: Reisyukaku/ReiNand
//Nand redirection
void loadEmu(void){ 
    //Read emunand code from SD
    getEmuCode(firmLocation, firmSize, &emuCodeOffset);
    memcpy((void*)emuCodeOffset, emunand, emunand_size);
    
    //Setup Emunand code
    uPtr *pos_sdmmc = (uPtr*)memsearch((void*)emuCodeOffset, "SDMC", emunand_size, 4);
    uPtr *pos_offset = (uPtr*)memsearch((void*)emuCodeOffset, "NAND", emunand_size, 4);
    uPtr *pos_header = (uPtr*)memsearch((void*)emuCodeOffset, "NCSD", emunand_size, 4);
    getSDMMC(firmLocation, firmSize, (void*)&sdmmcOffset);
    getEmuRW(firmLocation, firmSize, (void*)&emuRead, (void*)&emuWrite);
    *pos_sdmmc = sdmmcOffset;
    *pos_offset = emuOffset;
    *pos_header = emuHeader;
    
    //Add Emunand hooks
    memcpy((void*)emuRead, nandRedir, sizeof(nandRedir));
    memcpy((void*)emuWrite, nandRedir, sizeof(nandRedir));
}
示例#3
0
文件: firm.c 项目: Franc-Alo/ReiNand
//Nand redirection
void loadEmu(void){
    
    //Read emunand code from SD
    u32 code = emuCode();
    const char path[] = "/rei/emunand/emunand.bin";
    u32 size = fileSize(path);
    fileRead(code, path, size);
    
    //Find and patch emunand related offsets
    u32 *pos_sdmmc = memsearch(code, "SDMC", size, 4);
    u32 *pos_offset = memsearch(code, "NAND", size, 4);
    u32 *pos_header = memsearch(code, "NCSD", size, 4);
    getSDMMC(firmLocation, &sdmmcOffset, firmSize);
    getEmunandSect(&emuOffset, &emuHeader);
    getEmuRW(firmLocation, firmSize, &emuRead, &emuWrite);
    *pos_sdmmc = sdmmcOffset;
    *pos_offset = emuOffset;
    *pos_header = emuHeader;
    
    //Add emunand hooks
    memcpy((u8*)emuRead, nandRedir, sizeof(nandRedir));
    memcpy((u8*)emuWrite, nandRedir, sizeof(nandRedir));
    memcpy((u8*)mpuCode(), mpu, sizeof(mpu));
}