Exemplo n.º 1
0
        public void MakeFreeAreaList(byte[] data, uint RebuildAddress, Dictionary <uint, uint> useMap)
        {
            List <Address> knownList = U.MakeAllStructPointersList(false);
            List <DisassemblerTrumb.LDRPointer> ldrmap = Program.AsmMapFileAsmCache.GetLDRMapCache();

            U.AppendAllASMStructPointersList(knownList
                                             , ldrmap
                                             , isPatchInstallOnly: true
                                             , isPatchPointerOnly: false
                                             , isPatchStructOnly: false
                                             , isUseOtherGraphics: true
                                             , isUseOAMSP: true
                                             );
            MoveToFreeSapceForm.AppendSkillSystemsSanctuary(knownList);

            Dictionary <uint, bool> knownDic = MakeKnownListToDic(knownList);

            MakeFreeDataList(RecycleFreeAreaList, knownDic, FREEAREA_BLOCK_SIZE + 16 + 16, data, RebuildAddress, useMap);

            for (int i = 0; i < this.RecycleFreeAreaList.Count;)
            {
                Address p = this.RecycleFreeAreaList[i];

                //頭としっぽはくれてやれ
                if (p.Length < 64)
                {
                    this.RecycleFreeAreaList.RemoveAt(i);
                    continue;
                }
                p.ResizeAddress(p.Addr + 16, p.Length - 16 - 16);
                i++;
            }
        }
Exemplo n.º 2
0
        private InputFormRef.ADDR_AND_LENGTH get_data_pos_callback(uint addr)
        {
            uint length = CalcLength(addr);

            //範囲外探索 00 00 00 00 が続く限り検索してみる.
            uint more = MoveToFreeSapceForm.SearchOutOfRange(addr + length);

            //8バイトアライメント
            more = (more / 8) * 8;

            InputFormRef.ADDR_AND_LENGTH aal = new InputFormRef.ADDR_AND_LENGTH();
            aal.addr   = addr;
            aal.length = length + more;
            return(aal);
        }
Exemplo n.º 3
0
        uint SearchShareArea(byte[] bin)
        {
            //実はこのデータが既にROMにあったりしますか?
            uint foundAddr = U.Grep(this.WriteROMData32MB, bin, 0x100, this.WriteOffset, 4);

            if (foundAddr == U.NOT_FOUND)
            {
                return(U.NOT_FOUND);
            }

            if (MoveToFreeSapceForm.IsSkillReserve(ref foundAddr))
            {//SkillSystemsのエリアがある場合は再建策
                foundAddr = U.Grep(this.WriteROMData32MB, bin, foundAddr, this.WriteOffset, 4);
                if (foundAddr == U.NOT_FOUND)
                {
                    return(U.NOT_FOUND);
                }
            }
            //既にROMにあるので共有させましょう
            return(foundAddr);
        }
        public void MakeFreeAreaList(byte[] data, uint RebuildAddress, Dictionary <uint, uint> useMap)
        {
            List <Address> knownList = U.MakeAllStructPointersList(false);
            List <DisassemblerTrumb.LDRPointer> ldrmap = Program.AsmMapFileAsmCache.GetLDRMapCache();

            U.AppendAllASMStructPointersList(knownList
                                             , ldrmap
                                             , isPatchInstallOnly: true
                                             , isPatchPointerOnly: false
                                             , isPatchStructOnly: false
                                             , isUseOtherGraphics: true
                                             , isUseOAMSP: true
                                             );
            AsmMapFile.InvalidateUNUNSED(knownList);
            MoveToFreeSapceForm.AppendSkillSystemsSanctuary(knownList);

            Dictionary <uint, bool> knownDic = AsmMapFile.MakeKnownListToDic(knownList);

            MakeFreeDataList(RecycleFreeAreaList, knownDic, FreeAreaMinimumSize + FreeAreaPadding + FreeAreaPadding, data, RebuildAddress, useMap);

            for (int i = 0; i < this.RecycleFreeAreaList.Count;)
            {
                Address p = this.RecycleFreeAreaList[i];

                //頭としっぽはくれてやれ
                if (p.Length <= FreeAreaPadding * 2)
                {
                    this.RecycleFreeAreaList.RemoveAt(i);
                    continue;
                }
                p.ResizeAddress(p.Addr + FreeAreaPadding, p.Length - FreeAreaPadding - FreeAreaPadding);
                i++;
            }

            AppendFreeArea(RebuildAddress, this.AppendFreeAreaFilename);

            RecycleFreeAreaList.Sort((a, b) => { return(((int)a.Length) - ((int)b.Length)); });
        }
Exemplo n.º 5
0
        private void MoveButton_Click(object sender, EventArgs e)
        {
            uint moveAddr = U.toOffset((uint)MoveFromAddress.Value);
            uint toAddr   = U.toOffset((uint)MoveToAddress.Value);
            uint length   = (uint)MoveLength.Value;

            if (length == 0)
            {//自動推測できたらいいなあ
                return;
            }

            if (!U.isSafetyOffset(moveAddr) || !U.isSafetyOffset(moveAddr + length))
            {
                R.ShowStopError("FROMに指定されたアドレスがROMの範囲外です");
                return;
            }
            if (toAddr != 0)
            {
                if (!U.isSafetyOffset(toAddr) || !U.isSafetyOffset(toAddr + length))
                {
                    R.ShowStopError("TOに指定されたアドレスがROMの範囲外です");
                    return;
                }
            }
            DialogResult dr;

            {
                byte[] moveBytes = Program.ROM.getBinaryData(moveAddr, length);
                if (U.IsEmptyRange(moveBytes))
                {
                    R.ShowStopError("FROMに指定された{0}のコンテンツが全部nullです。\r\n既に移動済みの利用域をしていると思いますので、処理を停止します。", U.To0xHexString(moveAddr));
                    return;
                }
                if (toAddr != 0)
                {
                    byte[] toBytes = Program.ROM.getBinaryData(toAddr, length);
                    if (!U.IsEmptyRange(toBytes))
                    {
                        dr = R.ShowNoYes("TOに指定された{0}のコンテンツが全部nullではありません。\r\n既に別のデータで利用しているかもしれません。続行してもよろしいですか?", U.To0xHexString(toAddr));
                        if (dr != DialogResult.Yes)
                        {
                            return;
                        }
                    }
                }
            }

            dr = R.ShowNoYes("{0}から{1}までの領域({2} bytes)を{3}に移動してもよろしいですか?", U.To0xHexString(moveAddr), U.To0xHexString(moveAddr + length), length, U.To0xHexString(toAddr));
            if (dr != DialogResult.Yes)
            {
                return;
            }


            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                List <uint> movepointerlist = MoveToFreeSapceForm.SearchPointer(moveAddr);
                if (movepointerlist.Count != 1)
                {
                    dr = R.ShowNoYes("この移動で{0}か所のポインタの置換が行われます。\r\n本当に継続してもよろしいですか?", movepointerlist.Count);
                    if (dr != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }

            Undo.UndoData undodata = Program.Undo.NewUndoData(R._("MoveAddress {0}-{1} => {2} ({3}size)", U.To0xHexString(moveAddr), U.To0xHexString(moveAddr + length), U.To0xHexString(toAddr), length));
            uint          r        = InputFormRef.MoveBinaryData(this, moveAddr, toAddr, length, undodata);

            if (r == U.NOT_FOUND)
            {
                return;
            }
            Program.Undo.Push(undodata);
        }