Пример #1
0
        static Int32 Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Pass a rom file, output file, start address (HEX) and length to search for (Base 10 Integer)");
                return(1);
            }
            var rom = new RomDataWrapper(new FileInfo(args[0]));

            var outputFile = new FileInfo(args[1]);

            var from     = Int32.Parse(args[2], NumberStyles.HexNumber);
            var distance = Int32.Parse(args[3]);

            var foundPointers = new List <PointerText>();

            for (int i = 0; i < distance; i++)
            {
                var foundPointer = rom.GetOriginalPointerInfo(from + i);
                if (foundPointer.ReferenceCount > 0)
                {
                    foundPointers.Add(foundPointer);
                }
            }

            PointerText.WritePointersToFile(outputFile, foundPointers);

            return(0);
        }
Пример #2
0
 private static void LoadNewTranslationLinesTask(RomDataWrapper rom,
                                                 IEnumerable <Int32> linesToGet, List <PointerText> linestotranslate, Object lockObject, Int32 totalCount)
 {
     foreach (var line in linesToGet)
     {
         var lineTotranslate = rom.GetOriginalPointerInfo(line);
         lock (lockObject)
         {
             linestotranslate.Add(lineTotranslate);
             if (linestotranslate.Count % 100 == 0)
             {
                 Console.Write("\rReading progress: {0:##0}%   ", ((Decimal)linestotranslate.Count / totalCount) * 100);
             }
         }
     }
 }
Пример #3
0
 private static void LoadLinereferencesFromRomTask(RomDataWrapper rom,
                                                   IEnumerable <PointerText> lines, List <PointerText> linesWithReferences, Object lockObject, Int32 totalCount)
 {
     foreach (var line in lines)
     {
         var lineWithPointerInfo = rom.GetOriginalPointerInfo(line.Address);
         line.References = lineWithPointerInfo.References;
         lock (lockObject)
         {
             linesWithReferences.Add(line);
             if (linesWithReferences.Count % 100 == 0)
             {
                 Console.Write("\rProgress: {0:##0}%   ", ((Decimal)linesWithReferences.Count / totalCount) * 100);
             }
         }
     }
 }
Пример #4
0
        private static void ProcessBlocksTask(RomDataWrapper rom, IEnumerable <ValueTuple <Int32, Int32> > blocksToHandle, Int32 totalBlocks)
        {
            var previousBlock = (0, 0);

            foreach (var block in blocksToHandle)
            {
                var searchFrom = block.Item1 - 2;
                var searchTo   = searchFrom - maxBackSearch;
                if (previousBlock.Item2 > searchTo)
                {
                    searchTo = previousBlock.Item2;
                }

                Console.WriteLine("From {0,6} To {1,6} Length {2,4}", searchFrom, searchTo, searchTo - searchFrom);

                for (int i = searchFrom; i > searchTo; i--)
                {
                    var pointerText = rom.GetOriginalPointerInfo(i);
                    if (pointerText.ReferenceCount > 0 && (pointerText.Address + pointerText.AvailableLength) <= searchFrom)
                    {
                        lock (newTranslationLinesLockObject)
                        {
                            newTranslationLines.Add(i);
                        }
                        break; //we stop after first found pointer.
                    }
                }

                lock (processedBlocksLockObject)
                {
                    processedBlocks++;
                }

                previousBlock = block;

                Console.Write("\rScanning progress: {0:##0}%   ", ((Decimal)processedBlocks / totalBlocks) * 100);
            }
        }