Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 07:28

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C#] Multi level pointers

Discussion on [C#] Multi level pointers within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
davydavekk's Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 101
Received Thanks: 42
[C#] Multi level pointers

Hello epvps,

I'm writing a class for memory editing, but I'm stuck with multi lvl pointers.

What I have so far :
Code:
//API Declaration :

  [DllImport("kernel32.dll")]
    static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAdress,  byte[] lpBuffer, uint iSize,out uint lpNumberOfBytesRead);

    [DllImport("kernel32.dll")] // Overload for ptr
    static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAdress, out IntPtr lpBuffer, uint iSize, out uint lpNumberOfBytesRead);

//........

     public int Readlvl1Pointer(IntPtr adress)
    {
        uint bytesRead;
        byte[] _Value = new byte[4];

        ReadProcessMemory(_targetProcessHandle, adress, _Value, (uint)IntPtr.Size, out bytesRead);
        int ptrVal = BitConverter.ToInt32(_Value, 0);
        IntPtr ptr = (IntPtr)ptrVal;
        ReadProcessMemory(_targetProcessHandle, adress, _Value, (uint)IntPtr.Size, out bytesRead);

        return BitConverter.ToInt32(_Value, 0); // This function is working fine
    }

    private IntPtr ReadPointer(IntPtr adress)
    {
        IntPtr tempPTR;
        uint NumberOfBytesRead;

        ReadProcessMemory(_targetProcessHandle, adress, out tempPTR, (uint)IntPtr.Size, out NumberOfBytesRead);
        return tempPTR;
    }

    public IntPtr FollowPointer(IntPtr adress, ulong[] Offsets) // To get the final adress
    {
        IntPtr ptr = ReadPointer(adress);
        for (int i = 0; i < Offsets.Length; i++)
        {
            ptr = ReadPointer(new IntPtr(ptr + Offsets[i])); // error here, can't add IntPtr to IntPtr
        }
        return ptr;

    }
And I want to use like that (outside the class) :


Code:
IntPtr finalAdress = m.FollowPointer((IntPtr)0x0631390, {0xC,0x14,0});  // Don't know why I always have to convert here
m.WriteInteger(finalAdress,[new value here]);
Any help would be appreciated
davydavekk is offline  
Old 10/13/2013, 22:18   #2
 
elite*gold: 0
Join Date: May 2010
Posts: 88
Received Thanks: 23
just use ulong[] Offsets or uint
and ptr = ReadPointer(new IntPtr(ptr + Offsets[i]))
Easy-Emu is offline  
Thanks
1 User
Old 10/13/2013, 22:24   #3



 
Shawak's Avatar
 
elite*gold: 0
The Black Market: 259/0/0
Join Date: Apr 2010
Posts: 10,289
Received Thanks: 3,613
You are very mixed up with the data types there, you should try to fix that first.
Shawak is offline  
Thanks
1 User
Old 10/13/2013, 22:47   #4
 
davydavekk's Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 101
Received Thanks: 42
@Shawak : Updated for that.

@Easy-Emu : Still the same error:
Quote:
Operator '+' cannot be applied to operands of type 'System.IntPtr' and 'ulong'
davydavekk is offline  
Old 10/14/2013, 01:12   #5
 
elite*gold: 0
Join Date: May 2010
Posts: 88
Received Thanks: 23
ok then use
ReadPointer(new IntPtr((uint)ptr + (uint)Offsets[i]))

and uint[] Offsets
Easy-Emu is offline  
Thanks
1 User
Old 10/14/2013, 11:01   #6
 
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,149
KDeluxe is offline  
Old 10/14/2013, 18:40   #7
 
davydavekk's Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 101
Received Thanks: 42
Thanks Easy-Emu, it worked.

But now I have a problem with my others functions (I think it's because of the messed up data types, as Shawak said)

When I do :
Code:
Console.WriteLine(m.ReadInteger((IntPtr)0x7F758));
It returns a certain value, which is not the same as the value showed in CE (but it still the exact same adress).
And it change only when I use my WriteInteger function.

I missed something, but I don't know where.

My whole class :

Thanks in advance.
davydavekk is offline  
Old 10/15/2013, 09:56   #8
 
elite*gold: 0
Join Date: May 2010
Posts: 88
Received Thanks: 23
whats about baseAddress?^^
maybe you should make base+address
Easy-Emu is offline  
Old 10/16/2013, 02:09   #9
 
davydavekk's Avatar
 
elite*gold: 0
Join Date: May 2013
Posts: 101
Received Thanks: 42
Finally got it working, here's how I did :

Thank y'all.

#close request
davydavekk is offline  
Old 10/19/2013, 03:53   #10
 
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,149
A pointer can be larger than 4 bytes. You should use IntPtr instead of int.
KDeluxe is offline  
Reply


Similar Threads Similar Threads
[S][T]Level 18 GE5+multi servers
04/30/2013 - Browsergames Trading - 11 Replies
Great Accounts Sell or Trade for GA5 (Global America 5)Post offers below Global Europe 5 lvl18 just under 1 bill ep ship:goliath has diminisher 8 iris 1 apis 1 havoc
multi level pointers
07/03/2012 - AutoIt - 50 Replies
i have searched googled and so on and i cant figure out any of this shit. my pointer is with other offsets <?xml version="1.0"?> <CheatTable> <CheatEntries> <CheatEntry>
Multi Hack,Level Bot and Fish bot
07/04/2011 - Metin2 Private Server - 2 Replies
Multi Hack,Level Bot and Fish bot, just enter: BOT



All times are GMT +1. The time now is 07:28.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.