private IntPtr m_hProcess = IntPtr.Zero; //这个保存打开了个进程句柄 private void Form1_Load(object sender, EventArgs e) { try { pid = MemoryHelp.GetPidByProcessName("Xbox"); } catch { MessageBox.Show("抱歉,没有找到程序!"); Application.Exit(); } }
private void button1_Click(object sender, EventArgs e) { string ba = tx_baseadd.Text.Trim(); if (string.IsNullOrEmpty(ba)) { MessageBox.Show("请填入基地址"); return; } int jdz = 0; try { jdz = Convert.ToInt32("0x" + ba, 16); } catch { MessageBox.Show("填入的数据不正确"); return; } address1 = MemoryHelp.ReadMemoryValue(jdz, pid); address1 = address1 + 0x768; //获取2级地址 address1 = MemoryHelp.ReadMemoryValue(address1, pid); address1 = address1 + 0x5560; //获取存放阳光数值的地址 MemoryHelp.WriteMemoryValue(address1, 0x1869F, pid); //写入数据到地址(0x1869F表示99999) }