|
You last visited: Today at 07:28
Advertisement
[C#] Multi level pointers
Discussion on [C#] Multi level pointers within the .NET Languages forum part of the Coders Den category.
10/13/2013, 21:29
|
#1
|
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
|
|
|
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]))
|
|
|
10/13/2013, 22:24
|
#3
|
elite*gold: 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.
|
|
|
10/13/2013, 22:47
|
#4
|
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'
|
|
|
|
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
|
|
|
10/14/2013, 11:01
|
#6
|
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,149
|
|
|
|
10/14/2013, 18:40
|
#7
|
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.
|
|
|
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
|
|
|
10/16/2013, 02:09
|
#9
|
elite*gold: 0
Join Date: May 2013
Posts: 101
Received Thanks: 42
|
Finally got it working, here's how I did :
Code:
[DllImport("kernel32.dll")]
static extern bool ReadProcessMemory(IntPtr hProcess, int lpBaseAdress, byte[] lpBuffer, uint iSize, ref uint lpNumberOfBytesRead);
// ....
private int ReadPointer(int adress)
{
int ptrNext;
uint bytesRead = 0;
byte[] _Value = new byte[4];
ReadProcessMemory(_targetProcessHandle, adress, _Value, (uint)IntPtr.Size, ref bytesRead);
ptrNext = BitConverter.ToInt32(_Value, 0);
return ptrNext;
}
public int ReadFromPTR(int adress, int[] Offsets)
{
int ptr = ReadPointer(adress);
for (int i = 0; i < Offsets.Length -1; i++)
{
ptr = ReadPointer(ptr + Offsets[i]);
}
return ReadInteger(ptr + Offsets[Offsets.Length-1]);
}
Thank y'all.
#close request
|
|
|
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.
|
|
|
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.
|
|