1

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 : (";
                }
            }

1 Answer 1

1

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:

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, out IntPtr lpNumberOfBytesRead);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.