Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- public class PointerSearch
- {
- MemoryDumps memoryDumps;
- MemoryPointerData memoryPointer;
- public PointerSearch(String directoryPath) throws IOException
- {
- memoryDumps = new MemoryDumps(directoryPath);
- }
- public void performPointerSearch() throws IOException
- {
- long startingAddress;
- // The absolute memory address which marks the beginning of the game's RAM
- startingAddress = 0x14000000;
- memoryPointer = new MemoryPointerData(startingAddress, memoryDumps);
- memoryPointer.setMaximumOffset(0x400);
- findPossiblePointers(memoryPointer);
- }
- private void findPossiblePointers(MemoryPointerData pointer)
- {
- Debugging.printLine("Finding possible pointers:");
- for (int memoryDumpContentOffset = 0; memoryDumpContentOffset < memoryDumps
- .getMemoryDumpContents()[0].length; memoryDumpContentOffset++)
- {
- // Find values which look like possible pointer candidates
- if (pointer.isPossiblePointer(memoryDumps.getMemoryDumpContents()[0][memoryDumpContentOffset]))
- {
- // Calculate the offset between the address' value and the target address
- long pointerOffset = memoryDumps.getTargetAddresses()[0]
- + pointer.getLowestAddress()
- - memoryDumps.getMemoryDumpContents()[0][memoryDumpContentOffset];
- // We do not want pointers with negative or huge offsets
- if (!pointer.isWithinOffsetBounds(pointerOffset))
- {
- continue;
- }
- boolean allMatch = true;
- for (int memoryDumpsIndex = 1; memoryDumpsIndex < memoryDumps
- .getMemoryDumpsAmount(); memoryDumpsIndex++)
- {
- // Does the pointer we've found work on all of the RAM dumps supplied?
- if (memoryDumps.getMemoryDumpContents()[memoryDumpsIndex][memoryDumpContentOffset]
- + pointerOffset == memoryDumps.getTargetAddresses()[memoryDumpsIndex]
- + pointer.getLowestAddress())
- {
- // Debugging.printLine("Yes!");
- } else
- {
- // Debugging.printLine("No!");
- allMatch = false;
- }
- }
- // Print out pointers which seem reliable
- if (allMatch)
- {
- Debugging
- .printLine("["
- + HexadecimalUtilities
- .toHexadecimal(
- memoryDumpContentOffset
- + pointer
- .getLowestAddress())
- .substring(8)
- + "] + "
- + HexadecimalUtilities
- .toHexadecimal(pointerOffset));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement