|
You last visited: Today at 07:30
Advertisement
Reading pointers with offsets doesn´t work..
Discussion on Reading pointers with offsets doesn´t work.. within the .NET Languages forum part of the Coders Den category.
07/31/2017, 23:43
|
#1
|
elite*gold: 0
Join Date: Jul 2017
Posts: 1
Received Thanks: 0
|
Reading pointers with offsets doesn´t work..
Hey.
I have this class for reading from memory:
Code:
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace Game.Memory
{
class Memory
{
[DllImport("kernel32.dll")]
static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Boolean bInheritHandle, UInt32 dwProcessId);
[DllImport("kernel32.dll")]
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
byte[] lpBuffer, UIntPtr nSize, uint lpNumberOfBytesWritten);
[DllImport("Kernel32.dll")]
public static extern bool ReadProcessMemory(IntPtr handle, int address, byte[] bytes, int nsize, ref int op);
[DllImport("Kernel32.dll")]
public static extern bool WriteProcessMemory(IntPtr hwind, int Address, byte[] bytes, int nsize, out int output);
[DllImport("Kernel32.dll")]
public static extern IntPtr OpenProcess(int Token, bool inheritH, int ProcID);
IntPtr Handle;
public Memory(int sprocess)
{
Process Processes = Process.GetProcessById(sprocess);
Handle = OpenProcess(0x10, false, (uint)Processes.Id);
}
public string ReadString(int address, int nsize)
{
int Outp = 0;
byte[] BytesToRead = new byte[nsize];
ReadProcessMemory(Handle, address, BytesToRead, BytesToRead.Length, ref Outp);
return System.Text.Encoding.ASCII.GetString(BytesToRead);
}
public int ReadInt(int address, int nsize)
{
int OP = 0;
byte[] BytesToRead = new byte[nsize];
ReadProcessMemory(Handle, address, BytesToRead, BytesToRead.Length, ref OP);
return BitConverter.ToInt32(BytesToRead, 0);
}
public float ReadFloat(int address, int nsize)
{
int OP = 0;
byte[] BytesToRead = new byte[nsize];
ReadProcessMemory(Handle, address, BytesToRead, BytesToRead.Length, ref OP);
return (float)BitConverter.ToSingle(BytesToRead, 0);
}
public int ReadIntPtr(int address, int[] offsets, int Size = 4)
{
int MainAddress = address;
for (int i = 0; i < offsets.Length; i++)
{
MainAddress = ReadInt(MainAddress, Size) + offsets[i];
}
return MainAddress;
}
public float ReadFloatPtr( int address, int[] offsets, int Size = 4)
{
int AddressToWriteToo = ReadIntPtr(address, offsets);
float Data = ReadFloat(AddressToWriteToo, 4);
return Data;
}
public string ReadStringPtr(int address, int[] offsets, int ExspectedLength)
{
int AddressToRead = ReadIntPtr(address, offsets);
string TheString = ReadString(AddressToRead, ExspectedLength);
return TheString;
}
}
}
Now I have some pointer with differen types. Some are texts, some are numbers.
I already did it to read my Charactername (Pointer + Offset):
Code:
int pID= 13700;
int PlayerPointer = 0x16c0c18;
int GameTimePtr = 0x16c3cbc;
int GoldAddresse = 0x16c3fdc;
Memory mem = new Memory(LoLID);
Process GameProcess = Process.GetProcessById(pID);
IntPtr BaseAddress = GameProcess.MainModule.BaseAddress;
//Name
string Name = mem.ReadStringPtr( BaseAddress.ToInt32() + PlayerPointer, new int[] { 0x20}, 10);
textBox1.Text = Name;
This works.
Also I got the healthreader working:
Code:
int MaxHealth = (int)mem.ReadFloatPtr(BaseAddress.ToInt32() + PlayerPointer, new int[] { 0x660 });
But now i have some strange problems.
The first is another pointer (Value is 1-20).
I tried to get my Level with this:
Code:
int Level = mem.ReadIntPtr(BaseAddress.ToInt32() + PlayerPointer, new int[] { 0x3C5C });
The offset is right, but I get this:
1,401298E-45
Another problem is another number pointer with 2 offsets. Tried this:
Code:
lbGold.Text = mem.ReadFloatPtr(BaseAddress.ToInt32() + GoldAddresse, new int[] { 0x54, 0x44 }).ToString();
And I see the value is changing (right) but the value is 100% wrong. I get:
2,397622E-42
So where is the problem with these 2 reading codes? The offsets + addresses are correct.
Thank you
|
|
|
08/01/2017, 00:46
|
#2
|
elite*gold: 0
Join Date: Apr 2010
Posts: 10,289
Received Thanks: 3,613
|
How about debugging your software?
|
|
|
08/08/2017, 01:48
|
#3
|
elite*gold: 558
Join Date: Jan 2010
Posts: 22,776
Received Thanks: 10,538
|
General Coding -> .NET Languages
#moved
|
|
|
 |
Similar Threads
|
Help with reading memory with offsets from game
11/21/2013 - AutoIt - 17 Replies
As title say
I have next problem, i have base pointer + adress for solitaire on windows xp 32 bit
but when i enter it in script it returns me 0, but when i start computer and reload cheat engine it shows exact values from game
here is code
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
|
[C#]Reading Memory / Pointer with multiple Offsets.
01/12/2013 - .NET Languages - 23 Replies
I am used to coding in AutoIt. I am trying to move my project into C# but I have only about 2-3 weeks of experience.
In AutoIt, I have this code here that reads the process memory and returns a value.
$map = _MemoryRead(0x00B5CCB8, $handle) // Pointer address 0x00B5CCB8
$map = _MemoryRead($map + 0x02, $handle) // Offset 0x02
$map = _MemoryRead($map + 0xBD, $handle) // Second Offset 0xBD
I am trying desperately to convert this to C# language and I need some help. Here is what I have...
|
Can Anyone Share Metin2 Hack Source Or Offsets And Pointers
04/20/2009 - Metin2 - 1 Replies
Can Anyone Share Metin2 Hack Source Or Offsets And Pointers
|
neue offsets/pointers... compilen? bwh/bot... etc.
01/20/2006 - World of Warcraft - 0 Replies
hi leutz
also mein frage ist
wie und woher krieg ich die aktuellen pointers/offsets
wie baue ich das z.b in bwh ein..
oder den bot... etc.
ich hoffe ihr versteht was ich will...
wenn ich es falsch gepostet habe einfach verschieben...
da sich aber meine frage mehr auf wow bezieht denke ich mal das das hier her gehört...
|
Patch 1.9 Offsets and Pointers
01/09/2006 - WoW Exploits, Hacks, Tools & Macros - 0 Replies
// WoW [Release] Build 4937 (Dec 20 2005)
// WoW!Sharp.h
#define AutoStoreAllLootItems 0x4B0E00
#define CGBuffBar__m_buffs 0xB4CF28
#define CGBuffBar__m_durations 0xB4CE10
#define CGChat__AddChatMessage 0x48DC90
#define CGGameUI__ClearTarget 0x487C50
#define CGGameUI__LeftClick 0x486A00
#define CGGameUI__RightClick 0x486C50
#define CGGameUI__m_lockedTarget 0xAF60B8
|
All times are GMT +1. The time now is 07:30.
|
|