Exemplo n.º 1
0
        private static void FindStringPointers(String threadName, RomDataWrapper rom, int from, int to)
        {
            int prevEnd = from;

            for (int i = from; i < to; i++)
            {
                if (i % 10000 == 0)
                {
                    SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS); //Prevent system sleep.
                    Console.WriteLine("Finding thread {0} {1:#0}% done", threadName, ((Decimal)(i - from) / (to - from)) * 100);
                }

                var readByte = rom.RomContents[i];
                if (readByte == end)
                {
                    if (i - prevEnd > minStringLength)
                    {
                        var possibleTxt = prevEnd + 1;
                        if (existingtranslationLines.Contains(possibleTxt))
                        {
                            continue;
                        }

                        if (rom.IsTextReference(possibleTxt))
                        {
                            lock (newTranslationLinesLockObject)
                            {
                                newTranslationLines.Add(possibleTxt);
                            }
                        }
                        else
                        {
                            var backSearchLimit = (i - prevEnd < backSearch) ? i - prevEnd : backSearch;
                            for (int j = i - 1; j > (i - backSearchLimit + 1); j--)
                            {
                                if (rom.IsTextReference(j))
                                {
                                    lock (newTranslationLinesLockObject)
                                    {
                                        newTranslationLines.Add(j);
                                    }
                                    break; //we stop after first found pointer.
                                }
                            }
                        }
                    }
                    prevEnd = i;
                }
            }
        }
Exemplo n.º 2
0
        private static void FindStringPointers(String threadName, RomDataWrapper rom, int from, int to)
        {
            for (int i = from; i < to - 1; i++)
            {
                if (i % 10000 == 0)
                {
                    SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS); //Prevent system sleep.
                    Console.WriteLine("Finding thread {0} {1:#0}% done", threadName, ((Decimal)(i - from) / (to - from)) * 100);
                }

                var readByte = rom.RomContents[i];
                var nextByte = rom.RomContents[i + 1];
                if (readByte == end && nextByte != end)
                {
                    var possibleTxt = i + 1;
                    if (existingtranslationLines.Contains(possibleTxt))
                    {
                        continue;
                    }

                    if (rom.IsTextReference(possibleTxt))
                    {
                        lock (newTranslationLinesLockObject)
                        {
                            newTranslationLines.Add(possibleTxt);
                        }
                    }
                }
            }
        }