Write files using void

Hello from Baikonur!
The EEPROM dumper now uses void* for WriteFile(). As expected, this is untested because I obviously dont have the ability to bring a Wii U here.
This commit is contained in:
team-orangeBlue 2024-09-09 18:55:03 +05:00
parent cb02ef1040
commit e0ca079efb

View File

@ -12,13 +12,13 @@
namespace { namespace {
bool WriteFile(const uint8_t *source, const std::string& dstPath) bool WriteFile(const void *source, const std::string& dstPath)
{ {
FILE* outf = fopen(dstPath.c_str(), "wb"); FILE* outf = fopen(dstPath.c_str(), "wb");
if (!outf) { if (!outf) {
return false; return false;
} }
if (fwrite(source, 1, 4096, outf) != 0) { // DRC EEPROM size up until "DEADBABE" string appears to be 5E0h bytes, unless you dump the 2nd DRC. What the hell does it add..? if (fwrite(&source, 1, 4096, outf) != 0) { // DRC EEPROM size up until "DEADBABE" string appears to be 5E0h bytes, unless you dump the 2nd DRC. What the hell does it add..?
fclose(outf); fclose(outf);
return false; return false;
} }
@ -43,7 +43,7 @@ void EepromScreen::Draw()
} }
case STATE_DONE: { case STATE_DONE: {
Gfx::Print(Gfx::SCREEN_WIDTH / 2, Gfx::SCREEN_HEIGHT / 2, 64, Gfx::COLOR_TEXT, Gfx::Print(Gfx::SCREEN_WIDTH / 2, Gfx::SCREEN_HEIGHT / 2, 64, Gfx::COLOR_TEXT,
Utils::sprintf("Saved to eeprom.bin\nPress B"), Utils::sprintf("Saved to eeprom0.bin\nPress B"),
Gfx::ALIGN_CENTER); Gfx::ALIGN_CENTER);
break; break;
} }
@ -62,9 +62,9 @@ bool EepromScreen::Update(VPADStatus& input) // This is the core logic part
{ {
case STATE_DUMP: { case STATE_DUMP: {
CCRCDCEepromData readout0; CCRCDCEepromData readout0;
uint8_t readoutarray0[0x304]; //uint8_t readoutarray0[0x304];
CCRCDCEepromData readout1; // If a 2nd DRC is present, we will write this CCRCDCEepromData readout1; // If a 2nd DRC is present, we will write this
uint8_t readoutarray1[0x304]; //uint8_t readoutarray1[0x304];
// Read EEPROM // Read EEPROM
if(CCRCDCPerGetUicEeprom(CCR_CDC_DESTINATION_DRC0, &readout0) != 0){ if(CCRCDCPerGetUicEeprom(CCR_CDC_DESTINATION_DRC0, &readout0) != 0){
mErrorString = "Read failed!"; mErrorString = "Read failed!";
@ -73,20 +73,20 @@ bool EepromScreen::Update(VPADStatus& input) // This is the core logic part
} }
// Write to SD card // Write to SD card
// Convert to uint8_t so that this can be processed by fwrite // Convert to uint8_t so that this can be processed by fwrite
uint8_t versionarray0[4]; //uint8_t versionarray0[4];
for (int i=0; i<4 ;++i) //for (int i=0; i<4 ;++i)
versionarray0[i] = ((uint8_t*)&readout0.version)[3-i]; // versionarray0[i] = ((uint8_t*)&readout0.version)[3-i];
memcpy(&readoutarray0[0], versionarray0, 4); //memcpy(&readoutarray0[0], versionarray0, 4);
memcpy(&readoutarray0[4], readout0.data, 0x300); //memcpy(&readoutarray0[4], readout0.data, 0x300);
WriteFile(readoutarray0, "/vol/external01/eeprom0.bin"); WriteFile(&readout0, "/vol/external01/eeprom0.bin");
// If we read the DRC1 EEPROM // If we read the DRC1 EEPROM
if(CCRCDCPerGetUicEeprom(CCR_CDC_DESTINATION_DRC1, &readout1) == 0){ if(CCRCDCPerGetUicEeprom(CCR_CDC_DESTINATION_DRC1, &readout1) == 0){
uint8_t versionarray1[4]; //uint8_t versionarray1[4];
for (int i=0; i<4 ;++i) //for (int i=0; i<4 ;++i)
versionarray1[i] = ((uint8_t*)&readout1.version)[3-i]; // versionarray1[i] = ((uint8_t*)&readout1.version)[3-i];
memcpy(&readoutarray1[0], versionarray1, 4); //memcpy(&readoutarray1[0], versionarray1, 4);
memcpy(&readoutarray1[4], readout1.data, 0x300); //memcpy(&readoutarray1[4], readout1.data, 0x300);
WriteFile(readoutarray1, "/vol/external01/eeprom1.bin"); WriteFile(&readout1, "/vol/external01/eeprom1.bin");
} }
mState = STATE_DONE; mState = STATE_DONE;
break; break;