public static void initialize(Main pMain) { m_pMain = pMain; m_pWebClient = new CGWebClient(); m_pWebClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(m_pWebClient_DownloadFileCompleted); m_pWebClient.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(m_pWebClient_DownloadProgressChanged); if (!System.IO.File.Exists(@"pak\Files\tile.p000")) m_pWebClient.DownloadFile(WEBSITE + "launcher/new_patch.xml", "patch.xml"); else if (!System.IO.File.Exists(@"pak\World\_test$sample_1.p000")) m_pWebClient.DownloadFile(WEBSITE + "launcher/new_patch.xml", "patch.xml"); else m_pWebClient.DownloadFile(WEBSITE + "launcher/patch.xml", "patch.xml"); try { using (System.Xml.XmlTextReader pXmlTextReader = new System.Xml.XmlTextReader(Directory.GetCurrentDirectory() + "/patch.xml")) //using (System.Xml.XmlTextReader pXmlTextReader = new System.Xml.XmlTextReader( WEBSITE + "files/patch.xml")) { int x = 0; while (pXmlTextReader.ReadToFollowing("PATCHNODE")) { x++; m_pMain.Status = "Interpreting Patch Information " + x + "..."; if (pXmlTextReader.MoveToFirstAttribute()) { string strFilename = pXmlTextReader.GetAttribute("file").Replace("./", ""); string strCurrDir = System.IO.Directory.GetCurrentDirectory(); try { string Dir = Path.GetDirectoryName(strFilename); if (!Directory.Exists(Dir) && Dir != "") Directory.CreateDirectory(Dir); } catch { m_pMain.Status = "Failed to create or read folder info."; } //foreach (string strTemp in strFilename.Split('/')) //{ // if (!strTemp.Contains(".")) // { // System.IO.Directory.CreateDirectory(strTemp); // continue; // } //} uint nChecksum = 0; if (pXmlTextReader.ReadToFollowing("CHECKSUM")) { nChecksum = (uint)pXmlTextReader.ReadElementContentAs(typeof(uint), null); } try { FileInfo FI = new FileInfo(strFilename); if (strFilename.ToLower() == Path.GetFileName(Application.ExecutablePath).ToLower()) { FileInfo FI2 = new FileInfo(strFilename + "_"); if (FI2.Exists) FI2.Delete(); Thread.Sleep(500); FI.CopyTo(strFilename + "_"); uint crc = getFileCrc(strFilename + "_"); FI2 = new FileInfo(strFilename + "_"); if (FI2.Exists) FI2.Delete(); if (crc != nChecksum) { PatchSelf = true; m_pUpdateList.Add(strFilename); } continue; } if (!FI.Exists) m_pUpdateList.Add(strFilename); else { uint crc = getFileCrc(strFilename); if (crc != nChecksum) { m_pUpdateList.Add(strFilename); } } } catch (Exception E) { if (E.Message.Contains("msvcr71.dll' because it is being used by another process")) { //ignore because it's used by .net and gunz needs it... note that this is a possible abuse for exploitation } else { MessageBox.Show("Some of the files (" + strFilename + ") that need to be patched/edited are currently in use. Make sure SoulHunterZ is closed. If this error persists, restart your computer.", "Fatal Error"); Application.Exit(); } } System.IO.Directory.SetCurrentDirectory(strCurrDir); } } } } catch { m_pMain.Status = "Failed to get or read patch info."; m_pWebClient.Dispose(); return; } m_pMain.BarTotalMax = m_pUpdateList.Count; m_pMain.BarTotalVal = m_pMain.BarTotalMax; m_pMain.BarCurVal = m_pMain.BarCurMax; updateNext(); }