I am a newbie and trying to learn the C# ReadProcessMemory function!
As a training I am trying to read the HP value in "Conquer Online" so please tell me is this code right or wrong and will it cause me problems?
note: this is a console application
the program should read the HP address then it shows the value of the address!
PHP Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
[DllImport("kernel32.dll")]
public static extern int OpenProcess(
int dwDesiredAccess,
bool bInheritHandle,
int dwProcessId
);
[DllImport("kernel32.dll", EntryPoint = "CloseHandle")]
public static extern int CloseHandle(
int hObject
);
[DllImport("kernel32.dll")]
public static extern Int32 ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
byte[] buffer,
int size,
out int lpNumberOfBytesRead
);
static void Main(string[] args)
{
int PID;
PID = Process.GetProcessesByName("Conquer")[0].Id;
int hprocess = OpenProcess(0x0010, false, PID);
int num;
byte[] buffer = new byte[6];
ReadProcessMemory((IntPtr)hprocess, (IntPtr)0xE72E40, buffer, 4, out num);
CloseHandle(hprocess);
string x = Encoding.Default.GetString(buffer);
Console.WriteLine(x);
}
}
}






