Ejemplo n.º 1
0
        protected int Write(SakuraiEntryNode entry, int incAmt = 0)
        {
            if (entry != null)
            {
                //DEBUG
                if (entry._calcSize == 0 || entry._calcSize != entry.TotalSize)
                {
                    throw new Exception("Entry size issues");
                }

                int offset = entry.Write(_currentAddress);
                _currentAddress += incAmt > 0 ? incAmt : entry._calcSize;
            }
            return(0);
        }
Ejemplo n.º 2
0
        protected int Write(SakuraiEntryNode entry, int incAmt = 0)
        {
            if (entry != null)
            {
#if DEBUG
                if (entry._calcSize == 0 || entry._calcSize != entry.TotalSize)
                {
                    throw new Exception("Entry size issues");
                }
#endif

                int offset = entry.Write(_currentAddress);

                _currentLookup.AddRange(entry.LookupAddresses);
                _currentAddress += incAmt > 0 ? incAmt : entry._calcSize;

                return(offset);
            }
            return(0);
        }
Ejemplo n.º 3
0
        public unsafe void Write(SakuraiArchiveNode node, VoidPtr address, int length)
        {
            _baseAddress    = address + 0x20;
            _currentAddress = _baseAddress;

            //Write header
            SakuraiArchiveHeader *hdr = (SakuraiArchiveHeader *)address;

            hdr->_sectionCount            = _sectionCount;
            hdr->_externalSubRoutineCount = _referenceCount;
            hdr->_lookupEntryCount        = _lookupManager.Count;
            hdr->_fileSize = length;
            hdr->_pad1     = hdr->_pad2 = hdr->_pad3 = 0;

            List <int> _sectionOffsets = new List <int>();

            //Write section data
            foreach (TableEntryNode section in node.SectionList)
            {
                SakuraiEntryNode entry = section;

                //If this section is referenced from an entry,
                //write that entry instead
                if (section.References.Count > 0)
                {
                    entry = section.References[0];
                }

                _sectionOffsets.Add(entry.Write(_currentAddress));
                _currentAddress += entry.TotalSize;
            }

            //Write lookup values
            hdr->_lookupOffset = (int)_currentAddress - (int)_baseAddress;
            _lookupManager.Write(ref _currentAddress);

            //These can only be accessed after the lookup offset and count
            //have been written to the header.
            sStringEntry *sectionAddr = hdr->Sections;
            sStringEntry *refAddr     = hdr->ExternalSubRoutines;
        }
Ejemplo n.º 4
0
        protected unsafe void Write(SakuraiEntryNode entry, VoidPtr offsetAddr)
        {
            if (entry != null)
            {
#if DEBUG
                if (entry._calcSize == 0)
                {
                    throw new Exception("Entry size issues");
                }
#endif

                int offset = entry.Write(_currentAddress);

                _currentLookup.AddRange(entry.LookupAddresses);
                _currentAddress += entry._calcSize;

                *(bint *)offsetAddr = offset;
                Lookup(offsetAddr);
            }
            else
            {
                *(bint *)offsetAddr = 0;
            }
        }