Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C#]Read Pointers

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Thu Jul 09, 2009 2:24 pm    Post subject: [C#]Read Pointers Reply with quote

Base Address: 0a200e68
Offset: 30

I can't figure out how to read it =/

Any way I try even if it compiles it doesn't return the correct value.

_________________
Back to top
View user's profile Send private message AIM Address
mStorm
Expert Cheater
Reputation: 0

Joined: 21 Feb 2009
Posts: 107

PostPosted: Thu Jul 09, 2009 2:32 pm    Post subject: Reply with quote

Not exact code but you'll get the idea:

intptr base;
intptr addy;
ReadProcessMemory (0x0a200e68, &base, 4)
ReadProcessMemory(base+0x30, &addy, 4)
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Thu Jul 09, 2009 2:57 pm    Post subject: Reply with quote

Erm, I understand what you are trying to say but perhaps a slightly more complete snippet would give me a better concept of the idea.
_________________
Back to top
View user's profile Send private message AIM Address
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu Jul 09, 2009 3:11 pm    Post subject: Reply with quote

Code:

IntPtr Base = 0x0A200E68, Offset = 0x30;
int BaseValue,OffsetValue,dwReadBytes;
ReadProcessMemory(Process.Handle,Base,out BaseValue,4,out dwReadBytes);
ReadProcessMemory(Process.Handle,BaseValue + Offset,out OffsetValue,4, out dwBytesRead);

i'm pretty sure in C# it goes like that
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Thu Jul 09, 2009 3:45 pm    Post subject: Reply with quote

Can I see the signature you use to import?

I seem to have a different one.

_________________
Back to top
View user's profile Send private message AIM Address
hehewaffles
How do I cheat?
Reputation: 0

Joined: 23 Apr 2009
Posts: 5

PostPosted: Thu Jul 09, 2009 4:47 pm    Post subject: Reply with quote

Code:

//using System.Runtime.InteropServices;
[DllImport("kernel32.dll", SetLastError = true)]
internal static bool ReadProcessMemory(
    IntPtr hProcess,
    IntPtr lpBaseAddress,
    ref byte[] lpBuffer,
    uint nSize,
    ount uint lpNumberOfBytesRead
);

public int ReadValue(IntPtr hProcess)
{
    byte[] val = new byte[4]; uint BytesRead;
    if (!ReadProcessMemory(hProcess, 0x0A200E68, ref val, 4, out BytesRead) || BytesRead != 4)
        throw new Exception("Unable to read process! Error code: " + Marshal.GetLastWin32Error());

    if (!ReadProcessMemory(hProcess, BitConverter.ToInt32(val, 0) + 0x30, ref val, 4, out BytesRead) || BytesRead != 4)
         throw new Exception("Unable to read process! Error code: " + Marshal.GetLastWin32Error());

    return BitConverter.ToInt32(val, 0);
}
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Thu Jul 09, 2009 11:06 pm    Post subject: Reply with quote

anybody know what error code 6 is?
_________________
Back to top
View user's profile Send private message AIM Address
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Thu Jul 09, 2009 11:28 pm    Post subject: Reply with quote

i believe it's an invalid handle using
could you post your whole code here?
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Jul 10, 2009 12:22 am    Post subject: Reply with quote

yoyonerd wrote:
anybody know what error code 6 is?


http://msdn.microsoft.com/en-us/library/ms681381%28VS.85%29.aspx

ERROR_INVALID_HANDLE
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Fri Jul 10, 2009 7:45 am    Post subject: Reply with quote

you probably opened your process with PROCESS_ALL_ACCESS flag
you should use PROCESS_VM_READ flag
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Fri Jul 10, 2009 1:57 pm    Post subject: Reply with quote

1qaz wrote:
you probably opened your process with PROCESS_ALL_ACCESS flag
you should use PROCESS_VM_READ flag


Code:
private void Form1_Load(object sender, EventArgs e)
        {
            WindowHandle = FindWindow("WindowClass", null); // Establish a Window Handle (hWnd)
            GetWindowThreadProcessId(WindowHandle, out ProcID); // Get the Process ID (PID) from the targeted window/window class
            ProcessHandle = OpenProcess(0x1F0FFF, 1, ProcID); // Gain access to the process memory with OpenProcess() using Process ID as an entry

            this.Text = ReadValue(ProcessHandle).ToString();
        }


i think you are right, err i was just testing code thats why i make it set form title

_________________
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites