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#] ReadPointer
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Mon Dec 08, 2008 11:40 am    Post subject: [C#] ReadPointer Reply with quote

how would I read pointers in C#? I have looked everywhere..
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Mon Dec 08, 2008 11:46 am    Post subject: Reply with quote

..readprocessmemory ?
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Mon Dec 08, 2008 11:47 am    Post subject: Reply with quote

I knew that, but I don't think your getting my question.
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Mon Dec 08, 2008 12:02 pm    Post subject: Reply with quote

A pointer points to: the offset + the base address's value.
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Mon Dec 08, 2008 12:04 pm    Post subject: Reply with quote

Code:


        public byte[] Read(IntPtr handle, IntPtr address, UInt32 size, ref UInt32 bytes)
        {
            byte[] buffer = new byte[size];

            ReadProcessMemory(handle, address, buffer, size, ref bytes);
   

            Debug.Assert(bytes == size);

            return buffer;
        }

byte[] loloutput;

loloutput = Read(pHandle, (IntPtr)Addr, 4); //DWORD or ULONG pointer

IntPtr value = BitConverter.ToInt32(loloutput, 0);

Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Tue Dec 09, 2008 9:51 pm    Post subject: Reply with quote

so I would do this?

Code:
                byte[] memory = { 0x43e }; // OFFSET
                pKernel.ReadProcessMemory((IntPtr)ADDRESS, memory);

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Dec 09, 2008 10:06 pm    Post subject: Reply with quote

Wow guy.

It works exactly as you would expect. Read from the static address you hopefully worked your way down to, add the offset if needed.

Repeat until done.
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Tue Dec 09, 2008 10:23 pm    Post subject: Reply with quote

I can't just read the addy, because i'm trying to read character X and Y. So what I said will work or do I have to do something else?
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Dec 09, 2008 10:40 pm    Post subject: Reply with quote

What, you have a pointer to the character structure I'm guessing?

Like I said, read from the static address, then add the offset to what you get from it, repeat until you're done if necessarily.
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Wed Dec 10, 2008 11:04 am    Post subject: Reply with quote

AHAH! I got you now.

so it would be
Code:
IntPtr ADDR = (IntPtr)0xADDR + 0xOFFSET;
? ya know and then read it through a RPM.
_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Dec 10, 2008 12:25 pm    Post subject: Reply with quote

no

you want to add the offset to the contents that you got out of the static address you hopefully worked your way down too.


example, you've worked it down to 0x00123456.

BYTE offset = 0xAB;
ReadProcessMemory(handle, 0x00123456, &buffer, sizeof(buffer), 0);
buffer += offset;

buffer is now the contents of 0x00123456 + 0xAB and is hopefully pointing to the right address now.
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Wed Dec 10, 2008 3:13 pm    Post subject: Reply with quote

So to modify the value I would do

BYTE offset = 0xAB;
BYTE bytestowrite = 0x7F; // 7F = value in hex
WriteProcessMemory(handle, 0x00123456, &buffer, sizeof(buffer), bytestowrite);
buffer += offset;

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Wed Dec 10, 2008 3:44 pm    Post subject: Reply with quote

ElectroFusion wrote:
So to modify the value I would do

BYTE offset = 0xAB;
BYTE bytestowrite = 0x7F; // 7F = value in hex
WriteProcessMemory(handle, 0x00123456, &buffer, sizeof(buffer), bytestowrite);
buffer += offset;


Code:

unsigned base = 0x954A2F;
unsigned ptr;
ReadProcessMemory(hProcess, (void*)base, &ptr, 4, NULL);
ptr+=0x5D8;//Offset.
char writeval = 0x7F;
WriteProcessMemory(hProcess,(void*)ptr,&writeval,1,NULL);

_________________
Gone
Back to top
View user's profile Send private message
ElectroFusion
Grandmaster Cheater
Reputation: 0

Joined: 17 Dec 2006
Posts: 786

PostPosted: Thu Dec 11, 2008 12:27 pm    Post subject: Reply with quote

my RPM/WPM only takes 2 arguements, so it would have to be

Code:
loloutput = Read((IntPtr)Addr, 4);


Would this still work? or would it only work if I put it in a dll? (because read has no clue what handle)

_________________
qwerty147 wrote:

ghostonline wrote:

what world are you in?

bera

but i live in NZ
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Thu Dec 11, 2008 1:10 pm    Post subject: Reply with quote

ElectroFusion wrote:
my RPM/WPM only takes 2 arguements, so it would have to be

Code:
loloutput = Read((IntPtr)Addr, 4);


Would this still work? or would it only work if I put it in a dll? (because read has no clue what handle)

Ofcourse it won't work w/o a handle...

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

 
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