So I've decided to try and port some functions I created to this library. I am running into some issues converting a particular function shown below:
public static IntPtr FindAddress(IntPtr StaticPointer, int[] Offsets) { try { byte[] tmp = new byte[4]; IntPtr Address = BaseAddress + StaticPointer; foreach (int Offset in Offsets) { ReadProcessMemory(WowGameHandle, Address, tmp, tmp.Length, 0); Address = (IntPtr)BitConverter.ToInt32(tmp, 0) + Offset; Array.Clear(tmp, 0, tmp.Length); } return Address; } catch (Exception ex) { return IntPtr.Zero; } }
That piece of code is used to resolve the correct address from pointers for several other functions which in-turn read/write, and works fine on it's own with no problems what so ever. Now when I convert that to the following I get a few errors at run time about not being able to read 4 bytes from said address:
public static IntPtr FindAddress(IntPtr StaticPointer, int[] Offsets) { try { IntPtr Address = MemSharp.Read<IntPtr>(StaticPointer); //From my understanding this is re-based, so no need for adding base address foreach (int Offset in Offsets) Address = MemSharp.Read<IntPtr>(Address + Offset, false); //This should not be re-based because of 'false' flag return Address; } catch (Exception ex) { return IntPtr.Zero; } }
The said address is usually an invalid read which returns 0 + Offset which is not a valid address, and errors on the next read. I'm unsure if the other method below is any different, or just an alternate way to do things but it also has the same issue:
public static IntPtr FindAddress(IntPtr StaticPointer, int[] Offsets) { try { IntPtr Address = MemSharp[StaticPointer].Read<IntPtr>(); //From my understanding this is re-based, so no need for adding base address foreach (int Offset in Offsets) Address = MemSharp[Address + Offset, false].Read<IntPtr>(); //This should not be re-based because of 'false' flag return Address; } catch (Exception ex) { return IntPtr.Zero; } }
I've searched and found these informative posts on stack overflow, but they did not seem to resolve my issue:
http://stackoverflow...ess-not-working
http://stackoverflow...urning-anything
MemSharp is definitely being set to the correct process id, as all of the processes information is listed on hover over of the variable during a break point:
I can already see the potential in making the switch (chose this over blackmagic and some others), but it's just getting these little things ironed out before I can actually commit . Any help is appreciated in resolving the issue.
Edited by Abystus, 19 October 2013 - 08:51 AM.