为什么ReadProcessMemory返回的是0
一个老的单机游戏,自己想写个修改器,可是返回的是0
不知道是哪不对?帮我看看吧
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
[DllImport( "User32.dll ")]
public static extern int FindWindow(string s,string ss);
[DllImport( "Kernel32.dll ")]
public static extern int OpenProcess(int dwDesiredAccess, bool bInheritHandle,int dwProcessId);
[DllImport( "user32.dll ",EntryPoint = "GetWindowThreadProcessId ")]
public static extern int GetWindowThreadProcessId(int hWnd,ref int lpdwProcessId);
[DllImport( "kernel32.dll ")]
static extern bool ReadProcessMemory(uint hProcess,IntPtr lpBaseAddress, IntPtr lpBuffer, uint nSize, ref uint lpNumberOfBytesRead);
[DllImport( "Kernel32.dll ")]
public static extern int CloseHandle(int handle);
public void game()
{
const int PROCESS_VM_READ = 16;
int pid=0;
GetWindowThreadProcessId(Phandle,ref pid);
pro2=OpenProcess(PROCESS_VM_READ, false,pid);
textBox2.Text = pro2.ToString();
textBox4.Text = pid.ToString();
timer2.Enabled = true;
}
public Form1()
{
InitializeComponent();
}
int Phandle,pro2;