Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 20:32

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

Advertisement



Wie mehrere Pointer in C# "nutzen" (float)?

Discussion on Wie mehrere Pointer in C# "nutzen" (float)? within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
b0sted's Avatar
 
elite*gold: 110
Join Date: May 2010
Posts: 487
Received Thanks: 214
Wie mehrere Pointer in C# "nutzen" (float)?

Hi,
habe damit ein paar Probleme

Hier mein Code:
Code:
_mem mem = new _mem();
int[] offsetArr = { 0x684, 0xF4, 0xE0, 0x3C, 0x0, 0x17C, 0xFC };
MessageBox.Show(mem.ReadFloatPtr(0x017293C0, offsetArr).ToString());
_mem Class:
Code:
internal class _mem
	{
		enum AllocationType
		{
			Commit = 0x1000,
			Reserve = 0x2000,
			Decommit = 0x4000,
			Release = 0x8000,
			Reset = 0x80000,
			Physical = 0x400000,
			TopDown = 0x100000,
			WriteWatch = 0x200000,
			LargePages = 0x20000000
		}

		enum MemoryProtection
		{
			Proc_All_Access = 2035711,
		}

		[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);

		[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
		static extern IntPtr VirtualAllocEx(IntPtr hProcess, int lpAddress,
		uint dwSize, AllocationType flAllocationType, MemoryProtection flProtect);

		const string ProcessName = "b0sted";
		IntPtr rHandle = OpenProcess(0x10, false, Process.GetProcessesByName(ProcessName)[0].Id);
		IntPtr wHandle = OpenProcess((int)MemoryProtection.Proc_All_Access, false, Process.GetProcessesByName(ProcessName)[0].Id);


		//Reads a value then puts it into the BytesToRead var.
		//Reads a string from memory
		public string ReadString(int address, int nsize)
		{
			int Outp = 0;
			byte[] BytesToRead = new byte[nsize];

			ReadProcessMemory(rHandle, address, BytesToRead, BytesToRead.Length, ref Outp);

			return System.Text.Encoding.ASCII.GetString(BytesToRead);
		}

		//Reads a integer value from memory
		public int ReadInt(int address, int nsize)
		{
			int OP = 0;
			byte[] BytesToRead = new byte[nsize];
			ReadProcessMemory(rHandle, address, BytesToRead, BytesToRead.Length, ref OP);

			return BitConverter.ToInt32(BytesToRead, 0);
		}

		//Reads A Float Value
		public float ReadFloat(int address, int nsize)
		{
			int OP = 0;
			byte[] BytesToRead = new byte[nsize];
			ReadProcessMemory(rHandle, address, BytesToRead, BytesToRead.Length, ref OP);

			return (float)BitConverter.ToSingle(BytesToRead, 0);
		}

		public void WriteINT(int address, int value)
		{
			byte[] Bytes = BitConverter.GetBytes(value);
			int bytesWritten = 0;

			WriteProcessMemory(wHandle, address, Bytes, Bytes.Length, out bytesWritten);
		}


		public void WriteFloat(int address, float value)
		{
			byte[] Bytes = BitConverter.GetBytes(value);
			int BR = 0;
			WriteProcessMemory(wHandle, address, Bytes, Bytes.Length, out BR);
		}

		//Read & Write to multi level pointers
		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 void WriteIntPtr(int address, int[] offsets, int value)
		{
			int AddressToWriteToo = ReadIntPtr(address, offsets);
			WriteINT(AddressToWriteToo, value);
		}

		public float ReadFloatPtr(int address, int[] offsets, int Size = 4)
		{
			int AddressToWriteToo = ReadIntPtr(address, offsets);

			float Data = ReadFloat(AddressToWriteToo, 4);

			return Data;
		}

		public void WriteFloatPtr(int address, int[] offsets, float value)
		{
			int AddressToWriteToo = ReadIntPtr(address, offsets);
			WriteFloat(AddressToWriteToo, 0.0F);
		}

		public string ReadStringPtr(int address, int[] offsets, int ExspectedLength)
		{
			int AddressToRead = ReadIntPtr(address, offsets);

			string TheString = ReadString(AddressToRead, ExspectedLength);

			return TheString;
		}


		public void AllocateMemory(uint Amount, int[] offsets, int Address)
		{
			int AddressToAllocTo = ReadIntPtr(Address, offsets);
			VirtualAllocEx(wHandle, AddressToAllocTo, Amount, AllocationType.Commit, MemoryProtection.Proc_All_Access);
		}


		public void WriteStringPtr(int address, int[] offsets, string value)
		{
			int BaseAddress = ReadIntPtr(address, offsets);
			byte[] Data = System.Text.UnicodeEncoding.ASCII.GetBytes(value);
			int o = 0;
			WriteProcessMemory(wHandle, address, Data, Data.Length, out o);
		}

	}
Es kommt als Result immer "0" raus.
Es wäre super wenn mir jemand helfen könnte.
b0sted is offline  
Old 02/18/2020, 22:13   #2
 
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
U should pop the last offset before reading the float value
Code:
public float ReadFloatPtr(int address, int[] offsets, int Size = 4)
		{
//here goes your code to remove last element from int array
                        lastOffset = offsets.last //remove last element from pointer map

			int AddressToWriteToo = ReadIntPtr(address, offsets);

			float Data = ReadFloat(AddressToWriteToo + lastOffset, 4);

			return Data;
		}
Here is my implementation in python if you want to take a look:
elmarcia is offline  
Reply


Similar Threads Similar Threads
[Buying] """""PUBG Key""""""""
09/28/2017 - PlayerUnknown's Battlegrounds Trading - 5 Replies
Moin, ich suche noch einen Key von PUBG. Bezahle per PP.(kein Family& Friends) Nur mit RAT! mfg :mofo:
WEAPONSCRIPT!!!!!!!!!!!!!!!!!!!!!!!!!HOT"""""""""" """""""""""""""""""""
08/06/2011 - WarRock Hacks, Bots, Cheats & Exploits - 7 Replies
detetected



All times are GMT +1. The time now is 20:34.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.