Пример #1
0
        public void WriteAMem(IntPtr MemoryAddress, byte[] bytesToWrite, out int bytesWritten)
        {
            IntPtr ptrBytesWritten;

            PMC.WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);

            bytesWritten = ptrBytesWritten.ToInt32();
        }
Пример #2
0
        public void CloseHandle()
        {
            int iRetValue;

            iRetValue = PMC.CloseHandle(m_hProcess);
            if (iRetValue == 0)
            {
                throw new Exception("CloseHandle failed");
            }
        }
Пример #3
0
        public byte[] ReadAMem(IntPtr MemoryAddress, uint bytesToRead, out int bytesReaded)
        {
            byte[] buffer = new byte[bytesToRead];

            IntPtr ptrBytesReaded;

            PMC.ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesReaded);
            bytesReaded = ptrBytesReaded.ToInt32();
            return(buffer);
        }
Пример #4
0
        public static IntPtr FindDMAAddy(IntPtr hProc, IntPtr ptr, int[] offsets)
        {
            var buffer = new byte[IntPtr.Size];

            foreach (int i in offsets)
            {
                PMC.ReadProcessMemory(hProc, ptr, buffer, (uint)buffer.Length, out var read);

                ptr = (IntPtr.Size == 4)
                ? IntPtr.Add(new IntPtr(BitConverter.ToInt32(buffer, 0)), i)
                : ptr = IntPtr.Add(new IntPtr(BitConverter.ToInt64(buffer, 0)), i);
            }
            return(ptr);
        }
Пример #5
0
        public int ReadMem(int MemoryAddress, uint bytesToRead, out byte[] buffer)
        {
            IntPtr procHandle = PMC.OpenProcess(PMC.PROCESS_VM_READ | PMC.PROCESS_VM_WRITE | PMC.PROCESS_VM_OPERATION, 1, (uint)m_ReadProcess.Id);

            if (procHandle == IntPtr.Zero)
            {
                buffer = new byte[0];
                return(0);
            }

            buffer = new byte[bytesToRead];
            IntPtr ptrBytesReaded;

            PMC.ReadProcessMemory(procHandle, (IntPtr)MemoryAddress, buffer, bytesToRead, out ptrBytesReaded);
            PMC.CloseHandle(procHandle);
            return(ptrBytesReaded.ToInt32());
        }
Пример #6
0
        public int WriteMem(int MemoryAddress, byte[] buf)
        {
            IntPtr procHandle = PMC.OpenProcess(PMC.PROCESS_VM_READ | PMC.PROCESS_VM_WRITE | PMC.PROCESS_VM_OPERATION, 1, (uint)m_ReadProcess.Id);

            if (procHandle == IntPtr.Zero)
            {
                return(0);
            }

            uint oldProtect;

            PMC.VirtualProtectEx(procHandle, (IntPtr)MemoryAddress, (uint)buf.Length, PMC.PAGE_READWRITE, out oldProtect);
            IntPtr ptrBytesWritten;

            PMC.WriteProcessMemory(procHandle, (IntPtr)MemoryAddress, buf, (uint)buf.Length, out ptrBytesWritten);
            PMC.CloseHandle(procHandle);
            return(ptrBytesWritten.ToInt32());
        }
Пример #7
0
        //We use this to
        public int ReadMultiLevelPointer(int MemoryAddress, uint bytesToRead, Int32[] offsetList)
        {
            IntPtr procHandle = PMC.OpenProcess(PMC.PROCESS_VM_READ | PMC.PROCESS_VM_WRITE | PMC.PROCESS_VM_OPERATION, 1, (uint)m_ReadProcess.Id);
            IntPtr pointer    = (IntPtr)0x0;

            //IF THE PROCESS isnt available we return nothing
            if (procHandle == IntPtr.Zero)
            {
                return(0);
            }

            byte[] btBuffer     = new byte[bytesToRead];
            IntPtr lpOutStorage = IntPtr.Zero;

            int pointerAddy = MemoryAddress;

            //int pointerTemp = 0;
            for (int i = 0; i < (offsetList.Length); i++)
            {
                if (i == 0)
                {
                    PMC.ReadProcessMemory(
                        procHandle,
                        (IntPtr)(pointerAddy),
                        btBuffer,
                        (uint)btBuffer.Length,
                        out lpOutStorage);
                }
                pointerAddy = (BitConverter.ToInt32(btBuffer, 0) + offsetList[i]);
                //string pointerAddyHEX = pointerAddy.ToString("X");

                PMC.ReadProcessMemory(
                    procHandle,
                    (IntPtr)(pointerAddy),
                    btBuffer,
                    (uint)btBuffer.Length,
                    out lpOutStorage);
            }
            return(pointerAddy);
        }
Пример #8
0
 public void OpenProcess()
 {
     m_hProcess = PMC.OpenProcess(PMC.PROCESS_VM_READ | PMC.PROCESS_VM_WRITE | PMC.PROCESS_VM_OPERATION, 1, (uint)m_ReadProcess.Id);
 }