這是我的Form 1代碼:我如何找到一個過程的開始和結束內存?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace ReadMemory
{
public partial class Form1 : Form
{
List<int> memoryAddresses = new List<int>();
public Form1()
{
InitializeComponent();
Process proc = Process.GetCurrentProcess();
IntPtr startOffset = proc.MainModule.BaseAddress;
IntPtr endOffset = IntPtr.Add(startOffset, proc.MainModule.ModuleMemorySize);
for (int i = 0; i < startOffset.ToInt64(); i++)
{
memoryAddresses.Add(startOffset[i]
}
}
private void modelsToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}
}
我試圖從開始到結束掃描所有的內存地址,並將它們添加到列表中。 但我上線得到一個錯誤:
memoryAddresses.Add(startOffset[i]
錯誤3無法適用與[]的索引類型爲「System.IntPtr」
第二件事的表達在循環做:開始偏移.ToInt64()可以嗎?或者我應該做ToInt32()?
可能重複[添加偏移量到IntPtr](http://stackoverflow.com/questions/1866236/add-offset-to-intptr) – BartoszKP