Esempio n. 1
0
        public MonsterEntry( byte[] data, bool from3gpkm )
        {
            PropertyChangedEnabled = true;
            _data = new GameSection( data );
            _offset = 0;
            Storage = data.Length == 80;

            if( from3gpkm )
            {
                // definiton for 3gpkm-file is
                // decrypted subsection, with shuffle order GAEM
                // Fix by encrypting  incoming data and shifting personality to 0 before recrypting
                var personality = Personality;
                _data.SetInt( 0, 0 );
                _specificXor = new Cipher( 0, OriginalTrainerId );
                for( int i = 32; i < 80; i += 4 )
                {
                    SetEncryptedDWord( i, _data.GetInt( i ) );
                }
                Personality = personality;
                Checksum = CalculatedChecksum;
            }
            else
            {
                _specificXor = new Cipher( Personality, OriginalTrainerId );
            }
        }
Esempio n. 2
0
 public MonsterEntry( GameSection data, int offset, bool storage )
 {
     PropertyChangedEnabled = true;
     _data = data;
     _offset = offset;
     Storage = storage;
     _specificXor = new Cipher( Personality, OriginalTrainerId );
 }
Esempio n. 3
0
 public void TestXorCipher()
 {
     var c = new Cipher( 775683919 );
     Assert.AreEqual( 311364, c.Run( 775896843 ) );
 }
Esempio n. 4
0
        /// <summary>
        ///     When personality or original trainer changes, subsections need to move and be re-encrypted with new key.
        /// </summary>
        void Recrypt( uint newpersonality, uint newOTid )
        {
            uint[] oldG = ReadSubSection( GrowthOffset );
            uint[] oldA = ReadSubSection( ActionOffset );
            uint[] oldE = ReadSubSection( EVsOffset );
            uint[] oldM = ReadSubSection( MiscOffset );

            _data.SetInt( _offset, newpersonality );
            _data.SetInt( _offset + 4, newOTid );
            _specificXor = new Cipher( Personality, OriginalTrainerId );

            WriteSubSection( oldG, GrowthOffset );
            WriteSubSection( oldA, ActionOffset );
            WriteSubSection( oldE, EVsOffset );
            WriteSubSection( oldM, MiscOffset );
        }
Esempio n. 5
0
 public ItemEntry( GameSection data, int offset, Cipher xor )
 {
     _data = data;
     _offset = offset;
     _xor = xor;
 }
Esempio n. 6
0
        public GameSave( Stream instream )
        {
            _sections = new List<GameSection>();
            _originalOrderSections = new List<GameSection>();

            for( int i = 0; i < 14; i++ )
            {
                var section = new GameSection( instream );
                section.PropertyChanged += BubbleIsDirty;
                _originalOrderSections.Add( section );
            }
            _sections = _originalOrderSections.OrderBy( s => s.ID ).ToList();

            ExtractType();

            Xor = new Cipher( SecurityKey );

            Dex = new BindingList<DexEntry>();
            for( var i = 0; i < 416; i++ )
                Dex.Add( new DexEntry( i, this ) );

            ExtractTeam();
            ExtractPcBuffer();
            ExtractItems();
            GuessGame();
        }