Ejemplo n.º 1
0
        public byte[] ReadProcMem(int procId, IntPtr addressToRead, int lengthToRead)
        {
            if (Proc == IntPtr.Zero)
            {
                Proc = Unmanaged.OpenProcess(ProcessAccessRights.PROCESS_ALL_ACCESS, false, procId);
            }

            return(ReadProcMem(addressToRead, lengthToRead));
        }
Ejemplo n.º 2
0
        public int WriteProcMem(IntPtr procHandle, IntPtr addressToWrite, byte[] bytesToWrite)
        {
            if (Proc == IntPtr.Zero)
            {
                Proc = Unmanaged.OpenProcess(ProcessAccessRights.PROCESS_ALL_ACCESS, false, procHandle.ToInt32());
            }

            return(WriteProcMem(addressToWrite, bytesToWrite));
        }
Ejemplo n.º 3
0
 public Memory(int procId)
 {
     Proc = Unmanaged.OpenProcess(ProcessAccessRights.PROCESS_ALL_ACCESS, false, procId);
     if (Proc == IntPtr.Zero)
     {
         var error = new Win32Exception(Marshal.GetLastWin32Error());
         if (error.ErrorCode == 5)
         {
             throw new Exception(string.Format("ERROR: OpenProcess error {0} try running as admin.", error.ErrorCode));
         }
         throw new Exception(string.Format("ERROR: OpenProcess error {0}", error.Message));
     }
 }