From 0952399576bdd85daf7341175dba13259919c8b2 Mon Sep 17 00:00:00 2001 From: Shendo Date: Fri, 23 Apr 2021 04:01:53 +0200 Subject: [PATCH] Removed feature to auto fix corrupted cards and added it as the user selectable option because it conflicts with the newly discovered FreePSXBoot exploit --- .vs/MemcardRex/v16/.suo | Bin 32256 -> 59392 bytes MemcardRex/GUI/mainWindow.cs | 33 +++++++++---- MemcardRex/GUI/preferencesWindow.Designer.cs | 13 +++++ MemcardRex/GUI/preferencesWindow.cs | 2 + MemcardRex/GUI/preferencesWindow.resx | 4 +- MemcardRex/ps1card.cs | 47 +++++++++++-------- 6 files changed, 68 insertions(+), 31 deletions(-) diff --git a/.vs/MemcardRex/v16/.suo b/.vs/MemcardRex/v16/.suo index aa6839bad2dbc3822856ece26314ba82155c8821..205a21cfa07cfb5ee8b71a213fa8f13c6d191231 100644 GIT binary patch literal 59392 zcmeHQdypK(d7l%K%uB|AAlL?U5)#Ie_H>WEmxQEyO9CAdI=u)BXm5A!bf>-B%kG`- zKqmnpcBAnYN*D&Eu$R=`aFrem46u~;M zz-r}Qjd{KX$9m;Hmy<^Gx(UZ-fUJYa&Hld;&)Wd)fL=f~z#hZ>s=t7^?zz~X#E@qk z!1ZPTFbLQW7y=9f4geB>5x^)Q2~g=qvGf04^7Or#ld{Z~w37eP zwHWx2E{wl4#@ryr7`dSQp&I;06{0Nwuul0?Xxht&MA?DCi~jA_>a-@zJ?vKn2{op5EaSPX(_{r1y#s3WAa;!1iUE5;uceJoP@?o^!BNL0}gDrOLCAd@31#K>yEf`riRgA_?wd1d>P!N568f zoF7-3^pCtB=YhQMb-Wu7Nv|1p0&g04w_?>vV+HC1*Fzb69P1G!U5rYEX2^|(Sl5t#3y3*m*Meu*5z0{R4WaIBZ8FZ`( z2S5{(27ayqYDq*o`5y-Tr7nOvCBO6kGl(nce>Q%Bi7S!N1h=CcV`!BmT4Kn&D{=GK zWUhZpaqbuYLd2zxlVQ|odmT9!7cMmM6E}mOT+T-%i9fskMf86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XLxWD4fbThYF8W zxDFR|A?$dsbm5{_yy}dy#QEz23fwr~3h|>YN?_c(tNV|E0s7Yih4O+=8m2pt?!t2Q zSo$O?{Di{?=fhQd(ARs}Gi)CV;B!Cwk@6d2&m+~uf@}yjU)Twsc9p@cDI;g_>D2lO z-^FHO!~CB6(dEn7b9l;C2^AMgm#a#`waenpg%hT zgOhJxg}+Z+!=UPVSz0<)-hoqZUjfV=-V44L?BM%TsZigckhdm#;Yo)crf+6K+g2&# zdo8wPvOeTuzuzH2^v!85!1eJMT}Z|G`x0Z@c7-%}2FM~E+Qg*G6s5c-M{C3cTbbo> zxgDceN8f_{BksiIX?WqCIGE2FVdvy!^n>5Ep3Z#m_P1s{{UKe`7+76in7&pED|Q#- zt(X692(GqPgSlBd(LD9BHY>sgG1!_|2TUEm3H~3h%X{@$&G6YB(rYnu!xxH1$M+rh oe<^(1IE2TTs6l1X@K#098eu6#!8K-tnd8^tj&TVUZyOJM1ES5}kpKVy diff --git a/MemcardRex/GUI/mainWindow.cs b/MemcardRex/GUI/mainWindow.cs index 52884a8..8463edb 100644 --- a/MemcardRex/GUI/mainWindow.cs +++ b/MemcardRex/GUI/mainWindow.cs @@ -72,6 +72,7 @@ public struct programSettings public int backupMemcards; //Backup Memory Card settings public int warningMessage; //Warning message settings public int restoreWindowPosition; //Restore window position + public int fixCorruptedCards; //Try to fix corrupted memory cards public int glassStatusBar; //Vista glass status bar public int formatType; //Type of formatting for hardware interfaces public string listFont; //List font @@ -207,6 +208,9 @@ private void loadProgramSettings() //Load format type mainSettings.formatType = xmlAppSettings.readXmlEntryInt("HardwareFormatType", 0, 1); + //Load fix corrupted cards value + mainSettings.fixCorruptedCards = xmlAppSettings.readXmlEntryInt("FixCorruptedCards", 0, 1); + //Check if window position should be read if (mainSettings.restoreWindowPosition == 1) { @@ -266,6 +270,9 @@ private void saveProgramSettings() //Set format type xmlAppSettings.writeXmlEntry("HardwareFormatType", mainSettings.formatType.ToString()); + //Set fix corrupted cards value + xmlAppSettings.writeXmlEntry("FixCorruptedCards", mainSettings.fixCorruptedCards.ToString()); + //Set window X coordinate xmlAppSettings.writeXmlEntry("WindowX", this.Location.X.ToString()); @@ -276,6 +283,12 @@ private void saveProgramSettings() xmlAppSettings.closeXmlWriter(); } + //Quick and dirty settings bool converter + private bool getSettingsBool(int intValue) + { + return (intValue == 1) ? true : false; + } + //Backup a Memory Card private void backupMemcard(string fileName) { @@ -356,7 +369,7 @@ private void openCard(string fileName) PScard.Add(new ps1card()); //Try to open card - errorMsg = PScard[PScard.Count - 1].openMemoryCard(fileName); + errorMsg = PScard[PScard.Count - 1].openMemoryCard(fileName, getSettingsBool(mainSettings.fixCorruptedCards)); //If card is sucesfully opened proceed further, else destroy it if (errorMsg == null) @@ -449,7 +462,7 @@ private void saveCardDialog(int listIndex) //Save a Memory Card to a given filename private void saveMemoryCard(int listIndex, string fileName, byte memoryCardType) { - if (PScard[listIndex].saveMemoryCard(fileName, memoryCardType)) + if (PScard[listIndex].saveMemoryCard(fileName, memoryCardType, getSettingsBool(mainSettings.fixCorruptedCards))) { refreshListView(listIndex, cardList[listIndex].SelectedIndices[0]); refreshStatusStrip(); @@ -1660,7 +1673,7 @@ private void cardReaderRead(byte[] readData) PScard.Add(new ps1card()); //Fill the card with the new data - PScard[PScard.Count - 1].openMemoryCardStream(readData); + PScard[PScard.Count - 1].openMemoryCardStream(readData, getSettingsBool(mainSettings.fixCorruptedCards)); //Temporary set a bogus file location (to fool filterNullCard function) PScard[PScard.Count - 1].cardLocation = "\0"; @@ -2054,7 +2067,7 @@ private void dexDriveMenuWrite_Click(object sender, EventArgs e) if (PScard.Count > 0) { //Open a DexDrive communication window - new cardReaderWindow().writeMemoryCardDexDrive(this, appName, mainSettings.communicationPort, PScard[listIndex].saveMemoryCardStream(), 1024); + new cardReaderWindow().writeMemoryCardDexDrive(this, appName, mainSettings.communicationPort, PScard[listIndex].saveMemoryCardStream(getSettingsBool(mainSettings.fixCorruptedCards)), 1024); } } @@ -2087,7 +2100,7 @@ private void memCARDuinoMenuWrite_Click(object sender, EventArgs e) if (PScard.Count > 0) { //Open a DexDrive communication window - new cardReaderWindow().writeMemoryCardCARDuino(this, appName, mainSettings.communicationPort, PScard[listIndex].saveMemoryCardStream(), 1024); + new cardReaderWindow().writeMemoryCardCARDuino(this, appName, mainSettings.communicationPort, PScard[listIndex].saveMemoryCardStream(getSettingsBool(mainSettings.fixCorruptedCards)), 1024); } } @@ -2108,7 +2121,7 @@ private void pS1CardLinkMenuWrite_Click(object sender, EventArgs e) if (PScard.Count > 0) { //Open a DexDrive communication window - new cardReaderWindow().writeMemoryCardPS1CLnk(this, appName, mainSettings.communicationPort, PScard[listIndex].saveMemoryCardStream(), 1024); + new cardReaderWindow().writeMemoryCardPS1CLnk(this, appName, mainSettings.communicationPort, PScard[listIndex].saveMemoryCardStream(getSettingsBool(mainSettings.fixCorruptedCards)), 1024); } } @@ -2143,21 +2156,21 @@ private void formatHardwareCard(int hardDevice) if (mainSettings.formatType == 0) frameNumber = 64; //Create a new card by giving a null path - blankCard.openMemoryCard(null); + blankCard.openMemoryCard(null, true); //Check what device to use switch (hardDevice) { case 0: //DexDrive - new cardReaderWindow().writeMemoryCardDexDrive(this, appName, mainSettings.communicationPort, blankCard.saveMemoryCardStream(), frameNumber); + new cardReaderWindow().writeMemoryCardDexDrive(this, appName, mainSettings.communicationPort, blankCard.saveMemoryCardStream(true), frameNumber); break; case 1: //MemCARDuino - new cardReaderWindow().writeMemoryCardCARDuino(this, appName, mainSettings.communicationPort, blankCard.saveMemoryCardStream(), frameNumber); + new cardReaderWindow().writeMemoryCardCARDuino(this, appName, mainSettings.communicationPort, blankCard.saveMemoryCardStream(true), frameNumber); break; case 2: //PS1CardLink - new cardReaderWindow().writeMemoryCardPS1CLnk(this, appName, mainSettings.communicationPort, blankCard.saveMemoryCardStream(), frameNumber); + new cardReaderWindow().writeMemoryCardPS1CLnk(this, appName, mainSettings.communicationPort, blankCard.saveMemoryCardStream(true), frameNumber); break; } } diff --git a/MemcardRex/GUI/preferencesWindow.Designer.cs b/MemcardRex/GUI/preferencesWindow.Designer.cs index dd50f84..28215d1 100644 --- a/MemcardRex/GUI/preferencesWindow.Designer.cs +++ b/MemcardRex/GUI/preferencesWindow.Designer.cs @@ -51,6 +51,7 @@ private void InitializeComponent() this.formatLabel = new System.Windows.Forms.Label(); this.backgroundCombo = new System.Windows.Forms.ComboBox(); this.backgroundLabel = new System.Windows.Forms.Label(); + this.fixCorruptedCardsCheckbox = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // okButton @@ -288,11 +289,22 @@ private void InitializeComponent() this.backgroundLabel.TabIndex = 102; this.backgroundLabel.Text = "Icon background color:"; // + // fixCorruptedCardsCheckbox + // + this.fixCorruptedCardsCheckbox.AutoSize = true; + this.fixCorruptedCardsCheckbox.Location = new System.Drawing.Point(248, 132); + this.fixCorruptedCardsCheckbox.Name = "fixCorruptedCardsCheckbox"; + this.fixCorruptedCardsCheckbox.Size = new System.Drawing.Size(184, 17); + this.fixCorruptedCardsCheckbox.TabIndex = 103; + this.fixCorruptedCardsCheckbox.Text = "Try to fix corrupted Memory Cards"; + this.fixCorruptedCardsCheckbox.UseVisualStyleBackColor = true; + // // preferencesWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(463, 212); + this.Controls.Add(this.fixCorruptedCardsCheckbox); this.Controls.Add(this.backgroundCombo); this.Controls.Add(this.backgroundLabel); this.Controls.Add(this.formatLabel); @@ -353,5 +365,6 @@ private void InitializeComponent() private System.Windows.Forms.Label formatLabel; private System.Windows.Forms.ComboBox backgroundCombo; private System.Windows.Forms.Label backgroundLabel; + private System.Windows.Forms.CheckBox fixCorruptedCardsCheckbox; } } \ No newline at end of file diff --git a/MemcardRex/GUI/preferencesWindow.cs b/MemcardRex/GUI/preferencesWindow.cs index 36ca457..4b4c921 100644 --- a/MemcardRex/GUI/preferencesWindow.cs +++ b/MemcardRex/GUI/preferencesWindow.cs @@ -36,6 +36,7 @@ public void initializeDialog(mainWindow.programSettings progSettings) if (progSettings.glassStatusBar == 1) glassCheckbox.Checked = true; else glassCheckbox.Checked = false; if (progSettings.warningMessage == 1) backupWarningCheckBox.Checked = true; else backupWarningCheckBox.Checked = false; if (progSettings.restoreWindowPosition == 1) restorePositionCheckbox.Checked = true; else restorePositionCheckbox.Checked = false; + if (progSettings.fixCorruptedCards == 1) fixCorruptedCardsCheckbox.Checked = true; else fixCorruptedCardsCheckbox.Checked = false; //Load all COM ports found on the system foreach (string port in SerialPort.GetPortNames()) @@ -77,6 +78,7 @@ private void applySettings() if (glassCheckbox.Checked == true) progSettings.glassStatusBar = 1; else progSettings.glassStatusBar = 0; if (backupWarningCheckBox.Checked == true) progSettings.warningMessage = 1; else progSettings.warningMessage = 0; if (restorePositionCheckbox.Checked == true) progSettings.restoreWindowPosition = 1; else progSettings.restoreWindowPosition = 0; + if (fixCorruptedCardsCheckbox.Checked == true) progSettings.fixCorruptedCards = 1; else progSettings.fixCorruptedCards = 0; if (fontCombo.SelectedIndex != -1) progSettings.listFont = fontCombo.SelectedItem.ToString(); hostWindow.applyProgramSettings(progSettings); diff --git a/MemcardRex/GUI/preferencesWindow.resx b/MemcardRex/GUI/preferencesWindow.resx index 19dc0dd..d58980a 100644 --- a/MemcardRex/GUI/preferencesWindow.resx +++ b/MemcardRex/GUI/preferencesWindow.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/MemcardRex/ps1card.cs b/MemcardRex/ps1card.cs index d13d451..8c414fb 100644 --- a/MemcardRex/ps1card.cs +++ b/MemcardRex/ps1card.cs @@ -1,5 +1,5 @@ //PS1 Memory Card class -//Shendo 2009-2013 +//Shendo 2009-2021 using System; using System.Collections.Generic; @@ -88,20 +88,25 @@ private void loadDataFromRawCard() } //Recreate raw Memory Card - private void loadDataToRawCard() + private void loadDataToRawCard(bool fixData) { - //Clear existing data - rawMemoryCard = new byte[131072]; + //Check if data needs to be fixed or left as is (mandatory for FreePSXBoot) + if (fixData) + { + //Clear existing data + rawMemoryCard = new byte[131072]; - //Recreate the signature - rawMemoryCard[0] = 0x4D; //M - rawMemoryCard[1] = 0x43; //C - rawMemoryCard[127] = 0x0E; //XOR (precalculated) + //Recreate the signature + rawMemoryCard[0] = 0x4D; //M + rawMemoryCard[1] = 0x43; //C + rawMemoryCard[127] = 0x0E; //XOR (precalculated) - rawMemoryCard[8064] = 0x4D; //M - rawMemoryCard[8065] = 0x43; //C - rawMemoryCard[8191] = 0x0E; //XOR (precalculated) + rawMemoryCard[8064] = 0x4D; //M + rawMemoryCard[8065] = 0x43; //C + rawMemoryCard[8191] = 0x0E; //XOR (precalculated) + } + //This can be copied freely without fixing for (int slotNumber = 0; slotNumber < 15; slotNumber++) { //Load header data @@ -117,6 +122,10 @@ private void loadDataToRawCard() } } + + //Skip fixing data if it's not needed + if (!fixData) return; + //Create authentic data (just for completeness) for (int i = 0; i < 20; i++) { @@ -901,7 +910,7 @@ public bool openSingleSave(string fileName, int slotNumber, out int requiredSlot } //Save Memory Card to the given filename - public bool saveMemoryCard(string fileName, int memoryCardType) + public bool saveMemoryCard(string fileName, int memoryCardType, bool fixData) { BinaryWriter binWriter = null; @@ -916,7 +925,7 @@ public bool saveMemoryCard(string fileName, int memoryCardType) } //Prepare data for saving - loadDataToRawCard(); + loadDataToRawCard(fixData); //Check what kind of file to output according to memoryCardType switch (memoryCardType) @@ -953,10 +962,10 @@ public bool saveMemoryCard(string fileName, int memoryCardType) } //Save (export) Memory Card to a given byte stream - public byte[] saveMemoryCardStream() + public byte[] saveMemoryCardStream(bool fixData) { //Prepare data for saving - loadDataToRawCard(); + loadDataToRawCard(fixData); //Return complete Memory Card data return rawMemoryCard; @@ -964,7 +973,7 @@ public byte[] saveMemoryCardStream() //Open memory card from the given byte stream - public void openMemoryCardStream(byte[] memCardData) + public void openMemoryCardStream(byte[] memCardData, bool fixData) { //Set the reference for the recieved data rawMemoryCard = memCardData; @@ -974,7 +983,7 @@ public void openMemoryCardStream(byte[] memCardData) cardName = "Untitled"; - calculateXOR(); + if(fixData) calculateXOR(); loadStringData(); loadGMEComments(); loadSlotTypes(); @@ -989,7 +998,7 @@ public void openMemoryCardStream(byte[] memCardData) } //Open Memory Card from the given filename (return error message if operation is not sucessfull) - public string openMemoryCard(string fileName) + public string openMemoryCard(string fileName, bool fixData) { //Check if the Memory Card should be opened or created if (fileName != null) @@ -1070,7 +1079,7 @@ public string openMemoryCard(string fileName) } //Calculate XOR checksum (in case if any of the saveHeaders have corrputed XOR) - calculateXOR(); + if(fixData) calculateXOR(); //Convert various Memory Card data to strings loadStringData();