I'm trying to get string value from address which i found using cheat engine. I found for example 0x01742A38 and this is main part of my program (regular windows form application):
Process[] processes = Process.GetProcessesByName("Tibia");
foreach (Process p in processes)
{
IntPtr windowHandle = p.MainWindowHandle;
byte[] bufor = new byte[50];
uint baseAddress = (uint)p.MainModule.BaseAddress.ToInt32();
IntPtr addr = ((IntPtr)(baseAddress + 0x01742A38));
uint o = 0;
UInt32 k = 30;
if (ReadProcessMemory(windowHandle, addr, bufor, k, ref o))
{
label3.Text = "Success!";
}
else
{
label3.Text = "Fail : (";
}
}
Assuming your static address is correct, you have to open the target process using the OpenProcess function with at least the right PROCESS_VM_READ (0x0010).
I also suggest you to use a more suitable pinvoke signature for the function ReadProcessMemory: