コード例 #1
0
ファイル: HashCreator.cs プロジェクト: WarEmu/EasyMYP
        /// <summary>
        /// Treats the pattern and generates the filenames out of it
        /// </summary>
        public void Patterns(object obj)
        {
            Start(); // Sets this coding section to active

            patternTestHashDic = (HashDictionary)obj;

            patPlace = patternList.GetEnumerator();

            if (patternList.Count > 0)
            {
                threadList = new List<Thread>();
                for (int i = 0; i < System.Environment.ProcessorCount && i < HashCreatorConfig.MaxOperationThread; i++)
                {
                    Thread pat1 = new Thread(new ThreadStart(TreatPattern));
                    pat1.Start();
                    threadList.Add(pat1);
                }
                filenamesFoundInPatternTest = 0;

                //Wait for threads to terminate to update 'running' status
                for (int i = 0; i < System.Environment.ProcessorCount; i++)
                {
                    threadList[i].Join();
                }

                TriggerFilenameTestEvent(new MYPFilenameTestEventArgs(Event_FilenameTestType.PatternFinished, filenamesFoundInPatternTest));
            }
        }
コード例 #2
0
ファイル: HashCreator.cs プロジェクト: WarEmu/EasyMYP
 public HashCreator(HashDictionary hasher, Hasher.HasherType hasherType)
 {
     this.hashDic = hasher;
     this.hasherType = hasherType;
 }
コード例 #3
0
ファイル: Client.cs プロジェクト: JeFawk/WarEmu
        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());
            }
        }
コード例 #4
0
ファイル: MYPHandler.cs プロジェクト: Amver/easymyp
        long unCompressedSize = 0; //uncompressed size

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new myp worker
        /// </summary>
        /// <param name="filename">the name of the file to work with</param>
        /// <param name="event_FileTable">method to treat events return when reading the file table</param>
        /// <param name="event_Extraction">method to treat events return when extracting files</param>
        /// <param name="hasher">the dictionnary</param>
        public MYPHandler(string filename
            , del_FileTableEventHandler eventHandler_FileTable
            , del_FileEventHandler eventHandler_Extraction
            , HashDictionary hashDic)
        {
            this.hashDictionary = hashDic;
            if (eventHandler_Extraction != null)
                this.event_Extraction += eventHandler_Extraction;
            if (eventHandler_FileTable != null)
                this.event_FileTable += eventHandler_FileTable;

            //parse the filename to get the path
            this.currentMypFileName = filename.Substring(filename.LastIndexOf('\\') + 1, filename.Length - filename.LastIndexOf('\\') - 1);
            this.currentMypFileName = currentMypFileName.Split('.')[0];
            this.fullMypFileName = filename;
            if (filename.LastIndexOf('\\') >= 0)
            {
                this.mypPath = filename.Substring(0, filename.LastIndexOf('\\'));
            }
            else
            {
                this.mypPath = "";
            }

            //Initialize some data
            pattern = "*";
            unCompressedSize = 0;
            numberOfFileNamesFound = 0;
            totalNumberOfFiles = 0;
            numberOfFilesFound = 0;
            error_FileEntryNumber = 0;
            error_ExtractionNumber = 0;

            //open the archive file
            archiveStream = new FileStream(filename, FileMode.Open, FileAccess.Read);

            //read the position of the starting file table
            archiveStream.Seek(0x0C, SeekOrigin.Begin);
            byte[] buffer = new byte[8];
            archiveStream.Read(buffer, 0, buffer.Length);
            tableStart = FileInArchiveDescriptor.convertLittleEndianBufferToInt(buffer, 0);
            tableStart += ((long)FileInArchiveDescriptor.convertLittleEndianBufferToInt(buffer, 4)) << 32;
            GetFileNumber();

            //get the total memory available
            #region System Memory Management
            oSearcher = new ManagementObjectSearcher(oMs, oQuery);
            oReturnCollection = oSearcher.Get();

            foreach (ManagementObject oReturn in oReturnCollection)
            {
                totalMemory += Convert.ToDouble(oReturn["Capacity"]);
            }
            if (totalMemory <= programMemory)
            {
                programMemory = totalMemory / 2; //Security
            }
            #endregion
        }
コード例 #5
0
ファイル: Client.cs プロジェクト: dzikun/WarEmu
        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());
            }
        }
コード例 #6
0
ファイル: MainWindow.cs プロジェクト: Amver/easymyp
        private void testPatternButton_Click(object sender, EventArgs e)
        {
            if (t_GeneratePat == null) //reset in event handler
            {
                openArchiveDialog.Filter = "Pattern File|*.txt";
                if (openArchiveDialog.ShowDialog() != DialogResult.OK)
                    return;

                testPatternButton.Enabled = false;

                hashCreator.loadPatterns(openArchiveDialog.FileName);

                //make a copy of the dictionary to avoid conflicts, with only unknown file name to speed up.
                patternDic = new HashDictionary("Hash/PatternDic.txt");
                SortedList<long, HashData> subHashList;
                for (int i = 0; i < hashDic.HashList.Count; i++)
                {
                    subHashList = hashDic.HashList.Values[i];
                    foreach (KeyValuePair<long, HashData> kvp in subHashList)
                    {
                        if (kvp.Value.filename.CompareTo("") == 0)
                            patternDic.LoadHash(kvp.Value.ph, kvp.Value.sh, kvp.Value.filename, kvp.Value.crc, kvp.Value.archiveName);
                    }
                }

                hashCreator.event_FilenameTest += FilenameTestEventHandler; //reset in eventhandler

                t_GeneratePat = new Thread(new ParameterizedThreadStart(hashCreator.Patterns));
                t_GeneratePat.Start(patternDic);

                button_Pause.Enabled = true;
                button_Stop.Enabled = true;
            }
            else
                MessageBox.Show("Already testing! Please wait for completion", "Please wait", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }