Skip to content

Commit

Permalink
Merge pull request #85 from ComeInRage/main
Browse files Browse the repository at this point in the history
Add support for root-address flag when reading from saved sample
  • Loading branch information
Viir committed Jan 3, 2024
2 parents dde947d + 9c172c3 commit ae2fd88
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions implement/read-memory-64-bit/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ static int Main(string[] args)
return (memoryReader, uiRootCandidatesAddresses);
}
(IMemoryReader, IImmutableList<ulong>) GetMemoryReaderAndWithSpecifiedRootFromProcessSampleFile(byte[] processSampleFile, ulong rootAddress)
{
var processSampleId = Pine.CommonConversion.StringBase16FromByteArray(
Pine.CommonConversion.HashSHA256(processSampleFile));
Console.WriteLine($"Reading from process sample {processSampleId}.");
var processSampleUnpacked = ProcessSample.ProcessSampleFromZipArchive(processSampleFile);
var memoryReader = new MemoryReaderFromProcessSample(processSampleUnpacked.memoryRegions);
Console.WriteLine($"Reading UIRoot from specified address: {rootAddress}");
return (memoryReader, ImmutableList<ulong>.Empty.Add(rootAddress));
}
(IMemoryReader, IImmutableList<ulong>) GetMemoryReaderAndRootAddresses()
{
if (processId.HasValue)
Expand All @@ -141,6 +157,11 @@ static int Main(string[] args)
throw new Exception("Where should I read from?");
}
if (0 < rootAddressArgument?.Length)
{
return GetMemoryReaderAndWithSpecifiedRootFromProcessSampleFile(System.IO.File.ReadAllBytes(sourceFileArgument), ParseULong(rootAddressArgument));
}
return GetMemoryReaderAndRootAddressesFromProcessSampleFile(System.IO.File.ReadAllBytes(sourceFileArgument));
}
Expand Down

0 comments on commit ae2fd88

Please sign in to comment.