-
Member
I have been trying to use this for a couple of days now and have encountered a problem.
I honestly don't want to open a new thread for this since this seems to fit in here.
Whenever I try to use this function I get the "Tried to read/write protected Memory. Memory is corrupt." exception.
Code:
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
public delegate bool CGPlayer_C__ClickToMove(IntPtr pObject, int ClickToMoveType, IntPtr pGuid, IntPtr pClickPosition, float Precision);
public static CGPlayer_C__ClickToMove _ClickToMove;
[code]
function looks like this
Code:
public static void ClickToMove(Helper.WoWClickToMoveType Type, ulong tGuid, Helper.WoWPoint tPosition, float Precision)
{
if (ObjectManager.Me.ObjectPointer == IntPtr.Zero)
throw new NullReferenceException("ClickToMove invoked from an invalid Object");
if (Hooks._ClickToMove == null)
Hooks._ClickToMove = EntryPoint.Memory.RegisterDelegate<Hooks.CGPlayer_C__ClickToMove>(Statics.ClickToMoveAdress);
IntPtr pGuid = IntPtr.Zero;
IntPtr pPosition = IntPtr.Zero;
try
{
if (tGuid != 0)
{
pGuid = Marshal.AllocHGlobal(0x4 * 2);
EntryPoint.Memory.Write<ulong>(pGuid, tGuid);
}
if (!(tPosition.X == 0 && tPosition.Y == 0 && tPosition.Z == 0))
{
pPosition = Marshal.AllocHGlobal(0x4 * 3);
EntryPoint.Memory.Write<float>((uint)pPosition + 0x0, tPosition.X);
EntryPoint.Memory.Write<float>((uint)pPosition + 0x4, tPosition.Y);
EntryPoint.Memory.Write<float>((uint)pPosition + 0x8, tPosition.Z);
}
Hooks._ClickToMove(ObjectManager.Me.ObjectPointer, (int)Type, pGuid, pPosition, Precision);
}
finally
{
if (pGuid != IntPtr.Zero)
{
Marshal.FreeHGlobal(pGuid);
}
if (pPosition != IntPtr.Zero)
{
Marshal.FreeHGlobal(pPosition);
}
}
}
and I am using 0x006BA610 as Address.
by registering it like this
Code:
_ClickToMove = EntryPoint.Memory.RegisterDelegate<CGPlayer_C__ClickToMove>((uint)Statics.ClickToMoveAdress);
I have been trying with some help to fix this issue but it stays the same all the time.
My Dostring Hook works so I assume since it works kinda the same way that my ClickToMove Hook works too. I also checked the ObjPtr which is correct too.
If anyone sees where I am going wrong please let me know.
I am also ready to get flamed
-
Angry Penguin
If you're in process you can properly set up the delegate (since it looks like you are, as you're using my library)
Code:
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate byte CPlayerC_ClickToMove(IntPtr thisObj, int clickType, ref ulong guid, ref Point clickPos, float precision);
-
Member
Originally Posted by
Apoc
If you're in process you can properly set up the delegate (since it looks like you are, as you're using my library)
Code:
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate byte CPlayerC_ClickToMove(IntPtr thisObj, int clickType, ref ulong guid, ref Point clickPos, float precision);
Yes I am using your library.
With the help of Robske I found out that it will only throw the exception if the TargetGuid passed is 0. Atm I am by-passing this by passing my own guid if I am just walking somewhere.
-
Active Member
Originally Posted by
Azzie2k8
Yes I am using your library.
With the help of Robske I found out that it will only throw the exception if the TargetGuid passed is 0. Atm I am by-passing this by passing my own guid if I am just walking somewhere.
Pass a pointer to a ulong of 0, don't just pass 0.
-
Post Thanks / Like - 1 Thanks
Jirno (1 members gave Thanks to Scorpiona for this useful post)