private bool UpdateWar(string WarhammerDirectory) { FileStream fs = new FileStream(Application.StartupPath + "\\mythloginserviceconfig.xml", FileMode.Open, FileAccess.Read); Directory.SetCurrentDirectory(WarhammerDirectory); HashDictionary hashDictionary = new HashDictionary(); hashDictionary.AddHash(0x3FE03665, 0x349E2A8C, "mythloginserviceconfig.xml", 0); MYPHandler.MYPHandler mypHandler = new MYPHandler.MYPHandler("data.myp", null, null, hashDictionary); mypHandler.GetFileTable(); FileInArchive theFile = mypHandler.SearchForFile("mythloginserviceconfig.xml"); if (theFile == null) { MessageBox.Show("Can not find config file in data.myp"); return(false); } if (File.Exists(Application.StartupPath + "\\mythloginserviceconfig.xml") == false) { MessageBox.Show("Missing file : mythloginserviceconfig.xml"); return(false); } mypHandler.ReplaceFile(theFile, fs); fs.Close(); return(true); }
private void ExtractFiles(MYPHandler.MYPHandler mypHandler , List <FileInArchive> fileList) { //Check if an extraction path is set if (EasyMypConfig.ExtractionPath == null || mypHandler != null && mypHandler.ExtractionPath == "") { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { EasyMypConfig.ExtractionPath = folderBrowserDialog1.SelectedPath; mypHandler.ExtractionPath = EasyMypConfig.ExtractionPath; } else { return; } } if (mypHandler != null) { if (!SetOperationRunning()) { return; //reset in event } ProgressBarVisibilityUpdate(new EasyMYPProgressBarVisibilityEvent(statusPB , true, fileList.Count, 0)); t_worker = new Thread(new ParameterizedThreadStart(mypHandler.Extract)); t_worker.Start(fileList); } }
/// <summary> /// Treat file extraction events in the UI thread /// </summary> /// <param name="e"></param> private void TreatExtractionEvent(MYPHandler.MYPFileEventArgs e) { switch (e.State) { case Event_ExtractionType.ExtractionFinished: { OperationFinished(); UpdateLabel_OnExtraction(e.Value); break; } case Event_ExtractionType.FileExtractionError: { statusPB.Value = (int)e.Value; UpdateLabel_OnExtractionError(e.Value); break; } case Event_ExtractionType.FileExtracted: { statusPB.Value = (int)e.Value; UpdateLabel_OnExtraction(e.Value); break; } case Event_ExtractionType.Scanning: { // statusPB.Value += 1; // handled in another place: Update_OnFileTableEvent if (scanFiles.Count != 0) { CurrentMypFH = new MYPHandler.MYPHandler(scanFiles[0] , FileTableEventHandler, ExtractionEventHandler , hashDic); MypFHList.Add(scanFiles[0], CurrentMypFH); scanFiles.RemoveAt(0); CurrentMypFH.Pattern = Pattern.Text; t_worker = new Thread(new ThreadStart(CurrentMypFH.ScanFileTable)); t_worker.Start(); } else { OperationFinished(); } break; } } }
/// <summary> /// Parses all the myp files to extract all the possible hashes. /// </summary> /// private void scanAllMypsToolStripMenuItem_Click(object sender, EventArgs e) { multipleFilesScan = true; if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { string[] mypfiles = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.myp"); if (mypfiles.Length == 0) { MessageBox.Show("No myp files found in folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!SetOperationRunning()) { return; //reset in event handler } ResetOverall(); foreach (string file in mypfiles) { scanFiles.Add(file); } statusPB.Maximum = (int)mypfiles.Length; statusPB.Value = 0; statusPB.Visible = true; for (int i = 0; i < scanFiles.Count; i++) { if (MypFHList.ContainsKey(scanFiles[i])) { scanFiles.RemoveAt(i); i--; } } CurrentMypFH = new MYPHandler.MYPHandler(scanFiles[0] , FileTableEventHandler, ExtractionEventHandler , hashDic); MypFHList.Add(scanFiles[0], CurrentMypFH); CurrentMypFH.Pattern = Pattern.Text; t_worker = new Thread(new ThreadStart(CurrentMypFH.ScanFileTable)); t_worker.Start(); } }
private void OpenArchive(string filename) { if (!SetOperationRunning()) { return; //reset in eventhandler } ResetOverall(); // Huge problem here, resetOverall sets the operationRunning thingy to false... bad! //fileInArchiveBindingSource.Clear(); //Clean the filelisting fileInArchiveDataGridView.DataSource = null; // switched by when Event_FileTableType.Finished is received. LabelTextUpdate(new EasyMYPUpdateLabelsEvent(label_File_Value , filename.Substring(filename.LastIndexOf('\\') + 1))); if (!MypFHList.Keys.Contains(filename)) { //If we haven't open the file yet, we open it, set it as current, add it to the list CurrentMypFH = new MYPHandler.MYPHandler(filename , FileTableEventHandler, ExtractionEventHandler , hashDic); MypFHList.Add(filename, CurrentMypFH); //Beware here, the filename needs to be the full filename! Do not change it! } else { //Otherwise we load the old file CurrentMypFH = MypFHList[filename]; } if (EasyMypConfig.ExtractionPath != null) { CurrentMypFH.ExtractionPath = EasyMypConfig.ExtractionPath; } ProgressBarVisibilityUpdate(new EasyMYPProgressBarVisibilityEvent(statusPB , true, (int)CurrentMypFH.TotalNumberOfFiles, 0)); statusPB.Visible = true; LabelTextUpdate(new EasyMYPUpdateLabelsEvent(label_EstimatedNumOfFiles_Value , CurrentMypFH.TotalNumberOfFiles.ToString("#,#"))); CurrentMypFH.Pattern = Pattern.Text; t_worker = new Thread(new ThreadStart(CurrentMypFH.GetFileTable)); t_worker.Start(); }
public static void UpdateWarData() { if (ApocLauncher.Acc.AllowServerPatch) { try { _logger.Info("Updating mythloginserviceconfig.xml and data.myp"); FileStream fs = new FileStream(Application.StartupPath + "\\mythloginserviceconfig.xml", FileMode.Open, FileAccess.Read); Directory.SetCurrentDirectory(Directory.GetCurrentDirectory() + "\\..\\"); HashDictionary hashDictionary = new HashDictionary(); hashDictionary.AddHash(0x3FE03665, 0x349E2A8C, "mythloginserviceconfig.xml", 0); MYPHandler.MYPHandler mypHandler = new MYPHandler.MYPHandler("data.myp", null, null, hashDictionary); mypHandler.GetFileTable(); FileInArchive theFile = mypHandler.SearchForFile("mythloginserviceconfig.xml"); if (theFile == null) { _logger.Error("Can not find config file in data.myp"); return; } if (File.Exists(Application.StartupPath + "\\mythloginserviceconfig.xml") == false) { _logger.Error("Missing file : mythloginserviceconfig.xml"); return; } mypHandler.ReplaceFile(theFile, fs); fs.Close(); } catch (Exception e) { Print(e.ToString()); } } else { _logger.Info("Not Patching data.myp"); } }
private void updateMYP() { FileStream fs = new FileStream(Application.StartupPath + "\\PortalSettings.xml", FileMode.Open, FileAccess.Read); Directory.SetCurrentDirectory(path); HashDictionary hashDictionary = new HashDictionary(); hashDictionary.AddHash(0x3FE03665, 0x349E2A8C, "F4FCD464_3FE03665349E2A8C.xml", 0); MYPHandler.MYPHandler mypHandler = new MYPHandler.MYPHandler("data.myp", null, null, hashDictionary); mypHandler.GetFileTable(); FileInArchive theFile = mypHandler.SearchForFile("F4FCD464_3FE03665349E2A8C.xml"); mypHandler.ReplaceFile(theFile, fs); fs.Close(); if (theFile != null) { MessageBox.Show("patch success!"); } }
public static void UpdateWarData() { try { //FileStream fs = new FileStream(Application.StartupPath + "\\mythloginserviceconfig.xml", FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(Application.StartupPath.Remove(Application.StartupPath.LastIndexOf('\\')) + "\\mythloginserviceconfig.xml", FileMode.Open, FileAccess.Read); // Je Fawk | 13 April 2014 | Accessing the game folder path taken from Accueil from ServerLauncher try { Directory.SetCurrentDirectory(Accueil.pathToGameFolder); } catch (Exception exp) { MessageBox.Show("Error trying to set the current directory: " + exp.Message); return; } #region Old code //Directory.SetCurrentDirectory(Directory.GetCurrentDirectory() + "\\..\\"); #endregion HashDictionary hashDictionary = new HashDictionary(); hashDictionary.AddHash(0x3FE03665, 0x349E2A8C, "mythloginserviceconfig.xml", 0); MYPHandler.MYPHandler mypHandler = new MYPHandler.MYPHandler("data.myp", null, null, hashDictionary); mypHandler.GetFileTable(); FileInArchive theFile = mypHandler.SearchForFile("mythloginserviceconfig.xml"); if (theFile == null) { MessageBox.Show("Can not find config file in data.myp"); return; } // Je Fawk | 13 April 2014 | Modified the path from the Application.StartupPath which was the \Launcher\Launcher.exe if (File.Exists(Application.StartupPath.Remove(Application.StartupPath.LastIndexOf('\\')) + "\\mythloginserviceconfig.xml") == false) #region Old code //if (File.Exists(Application.StartupPath + "\\mythloginserviceconfig.xml") == false) #endregion { MessageBox.Show("Missing file : mythloginserviceconfig.xml"); return; } mypHandler.ReplaceFile(theFile, fs); fs.Close(); } catch (Exception e) { Print(e.ToString()); } }
/// <summary> /// Parses all the myp files to extract all the possible hashes. /// </summary> /// private void scanAllMypsToolStripMenuItem_Click(object sender, EventArgs e) { multipleFilesScan = true; if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { string[] mypfiles = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.myp"); if (mypfiles.Length == 0) { MessageBox.Show("No myp files found in folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!SetOperationRunning()) return; //reset in event handler ResetOverall(); foreach (string file in mypfiles) { scanFiles.Add(file); } statusPB.Maximum = (int)mypfiles.Length; statusPB.Value = 0; statusPB.Visible = true; for (int i = 0; i < scanFiles.Count; i++) { if (MypFHList.ContainsKey(scanFiles[i])) { scanFiles.RemoveAt(i); i--; } } CurrentMypFH = new MYPHandler.MYPHandler(scanFiles[0] , FileTableEventHandler, ExtractionEventHandler , hashDic); MypFHList.Add(scanFiles[0], CurrentMypFH); CurrentMypFH.Pattern = Pattern.Text; t_worker = new Thread(new ThreadStart(CurrentMypFH.ScanFileTable)); t_worker.Start(); } }
/// <summary> /// Treats an event in the UI thread /// </summary> /// <param name="e">event arguments</param> private void TreatFileTableEvent(MYPHandler.MYPFileTableEventArgs e) { modulus++; if (e.Type == Event_FileTableType.FileError) { label_ReadingErrors_Value.Text = CurrentMypFH.Error_FileEntryNumber.ToString(); } else if (e.Type == Event_FileTableType.NewFile) { if (modulus % 1000 == 0 && !multipleFilesScan) { Update_OnFileTableEvent(); } FileListing_Add(e.ArchFile); } else if (e.Type == Event_FileTableType.UpdateFile) { if (modulus % 1000 == 0) { Update_OnFileTableEvent(); } } else if (e.Type == Event_FileTableType.Finished) { //Final update Update_OnFileTableEvent(); if (CurrentMypFH.archiveModifiedFileList.Count > 0 || CurrentMypFH.archiveNewFileList.Count > 0) { hashDic.SaveHashList(); } //if (!multipleFilesScan || scanFiles.Count == 0) // so that we only update the tree view and everything at the whole end, to take less time when multiple scans is running //{ fileInArchiveDataGridView.DataSource = fileInArchiveBindingSource; //fileInArchiveDataGridView.Show(); Update_TreeView(); //} if (scanFiles.Count == 0) OperationFinished(); // Only if all the files have been scan is the operation finished !!! } }
private void ExtractionEventHandler(object sender, MYPHandler.MYPFileEventArgs e) { if (label_ExtractionErrors_Text.InvokeRequired) { Invoke(OnNewExtractedEvent, e); } else { TreatExtractionEvent(e); } }
/// <summary> /// Receive all events related to the file table entries /// </summary> /// <param name="sender">sender</param> /// <param name="e">event args</param> private void FileTableEventHandler(object sender, MYPHandler.MYPFileTableEventArgs e) { //Check if an invoke is required by selecting a random component //that might be updated by this event if (label_NumOfFiles_Value.InvokeRequired) { Invoke(OnNewFileTableEvent, e); } else { TreatFileTableEvent(e); } }
static public void UpdateWarData() { try { FileStream fs = new FileStream(Application.StartupPath + "\\mythloginserviceconfig.xml", FileMode.Open, FileAccess.Read); Directory.SetCurrentDirectory(Directory.GetCurrentDirectory() + "\\..\\"); HashDictionary hashDictionary = new HashDictionary(); hashDictionary.AddHash(0x3FE03665, 0x349E2A8C, "mythloginserviceconfig.xml", 0); MYPHandler.MYPHandler mypHandler = new MYPHandler.MYPHandler("data.myp", null, null, hashDictionary); mypHandler.GetFileTable(); FileInArchive theFile = mypHandler.SearchForFile("mythloginserviceconfig.xml"); if (theFile == null) { MessageBox.Show("Can not find config file in data.myp"); return; } if (File.Exists(Application.StartupPath + "\\mythloginserviceconfig.xml") == false) { MessageBox.Show("Missing file : mythloginserviceconfig.xml"); return; } mypHandler.ReplaceFile(theFile, fs); fs.Close(); } catch (Exception e) { Print(e.ToString()); } }
/// <summary> /// Parses all the myp files to extract all the possible hashes. /// </summary> /// private void scanAllTorsToolStripMenuItem_Click(object sender, EventArgs e) { multipleFilesScan = true; if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { string[] mypfiles = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.tor"); if (mypfiles.Length == 0) { MessageBox.Show("No tor files found in folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!SetOperationRunning()) return; //reset in event handler ResetOverall(); foreach (string file in mypfiles) { scanFiles.Add(file); } statusPB.Maximum = (int)mypfiles.Length; statusPB.Value = 0; statusPB.Visible = true; //if (!MypFHList.Keys.Contains(scanFiles[0])) //{ // //If we haven't open the file yet, we open it, set it as current, add it to the list // CurrentMypFH = new MYPHandler.MYPHandler(scanFiles[0] // , FileTableEventHandler, ExtractionEventHandler // , hashDic); // MypFHList.Add(scanFiles[0], CurrentMypFH); //} //else //{ // //Otherwise we load the old file // CurrentMypFH = MypFHList[scanFiles[0]]; //} for (int i = 0; i < scanFiles.Count; i++) { if (MypFHList.ContainsKey(scanFiles[i])) { scanFiles.RemoveAt(i); i--; } } CurrentMypFH = new MYPHandler.MYPHandler(scanFiles[0] , FileTableEventHandler, ExtractionEventHandler , hashDic); MypFHList.Add(scanFiles[0], CurrentMypFH); scanFiles.RemoveAt(0); CurrentMypFH.Pattern = Pattern.Text; t_worker = new Thread(new ThreadStart(CurrentMypFH.ScanFileTable)); t_worker.Start(); } }
/// <summary> /// Parses all the myp files to extract all the possible hashes. /// </summary> /// private void scanAllTorsToolStripMenuItem_Click(object sender, EventArgs e) { multipleFilesScan = true; if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { string[] mypfiles = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.tor"); if (mypfiles.Length == 0) { MessageBox.Show("No tor files found in folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!SetOperationRunning()) { return; //reset in event handler } ResetOverall(); foreach (string file in mypfiles) { scanFiles.Add(file); } statusPB.Maximum = (int)mypfiles.Length; statusPB.Value = 0; statusPB.Visible = true; //if (!MypFHList.Keys.Contains(scanFiles[0])) //{ // //If we haven't open the file yet, we open it, set it as current, add it to the list // CurrentMypFH = new MYPHandler.MYPHandler(scanFiles[0] // , FileTableEventHandler, ExtractionEventHandler // , hashDic); // MypFHList.Add(scanFiles[0], CurrentMypFH); //} //else //{ // //Otherwise we load the old file // CurrentMypFH = MypFHList[scanFiles[0]]; //} for (int i = 0; i < scanFiles.Count; i++) { if (MypFHList.ContainsKey(scanFiles[i])) { scanFiles.RemoveAt(i); i--; } } CurrentMypFH = new MYPHandler.MYPHandler(scanFiles[0] , FileTableEventHandler, ExtractionEventHandler , hashDic); MypFHList.Add(scanFiles[0], CurrentMypFH); scanFiles.RemoveAt(0); CurrentMypFH.Pattern = Pattern.Text; t_worker = new Thread(new ThreadStart(CurrentMypFH.ScanFileTable)); t_worker.Start(); } }
private void OpenArchive(string filename) { if (!SetOperationRunning()) return; //reset in eventhandler ResetOverall(); // Huge problem here, resetOverall sets the operationRunning thingy to false... bad! //fileInArchiveBindingSource.Clear(); //Clean the filelisting fileInArchiveDataGridView.DataSource = null; // switched by when Event_FileTableType.Finished is received. LabelTextUpdate(new EasyMYPUpdateLabelsEvent(label_File_Value , filename.Substring(filename.LastIndexOf('\\') + 1))); if (!MypFHList.Keys.Contains(filename)) { //If we haven't open the file yet, we open it, set it as current, add it to the list CurrentMypFH = new MYPHandler.MYPHandler(filename , FileTableEventHandler, ExtractionEventHandler , hashDic); MypFHList.Add(filename, CurrentMypFH); //Beware here, the filename needs to be the full filename! Do not change it! } else { //Otherwise we load the old file CurrentMypFH = MypFHList[filename]; } if (EasyMypConfig.ExtractionPath != null) { CurrentMypFH.ExtractionPath = EasyMypConfig.ExtractionPath; } ProgressBarVisibilityUpdate(new EasyMYPProgressBarVisibilityEvent(statusPB , true, (int)CurrentMypFH.TotalNumberOfFiles, 0)); statusPB.Visible = true; LabelTextUpdate(new EasyMYPUpdateLabelsEvent(label_EstimatedNumOfFiles_Value , CurrentMypFH.TotalNumberOfFiles.ToString("#,#"))); CurrentMypFH.Pattern = Pattern.Text; t_worker = new Thread(new ThreadStart(CurrentMypFH.GetFileTable)); t_worker.Start(); }
private void ExtractFiles(MYPHandler.MYPHandler mypHandler , List<FileInArchive> fileList) { //Check if an extraction path is set if (EasyMypConfig.ExtractionPath == null || mypHandler != null && mypHandler.ExtractionPath == "") { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { EasyMypConfig.ExtractionPath = folderBrowserDialog1.SelectedPath; mypHandler.ExtractionPath = EasyMypConfig.ExtractionPath; } else return; } if (mypHandler != null) { if (!SetOperationRunning()) return; //reset in event ProgressBarVisibilityUpdate(new EasyMYPProgressBarVisibilityEvent(statusPB , true, fileList.Count, 0)); t_worker = new Thread(new ParameterizedThreadStart(mypHandler.Extract)); t_worker.Start(fileList); } }