-
Member
CastSpellByID by UnitGUID
Hi guys, please tell me how to solve the problem?
Code:
public void CastSpellById(int id, ulong GUID = 0)
{
string[] code = new string[]
{
"fs mov eax, [0x2C]",
"mov eax, [eax]",
"add eax, 0x8",
"mov dword [eax], " + (uint)СMgr,
"push 0",
"push "+ GUID,
"push 0",
"push "+ id,
"call "+ (uint)CastSpell, //0x0084DF20
"add esp,0x14",
"retn"
}
};
This code works only with players, when using MobGUID, gives an error.
error 120: size 4 bites.
I understand that it is necessary to increase the volume of the cell, but I don’t know.
Im sorry for my bad English, I study it using Google Translate =)
-
Active Member
Edit- Read the post after just waking up, what I had here before was totally wrong
Ok so let's break this down.
The problem you have is that you are trying to push 8 bytes where you only have room for 4 bytes. The code you posted hints at the solution.
Code:
"push 0",
"push "+ GUID,
I dont know what patch you are looking at, but this looks like the solution. The function is expecting 8 bytes, here it is pushing 4 bytes twice.
So instead of
Code:
"push 0", // Room for 4 bytes
"push "+ GUID(8 bytes), // Room for 4 bytes
you should be doing
Code:
"push " + (1st half of GUID), // Room for 4 bytes
"push "+ (2nd half of GUID), // Room for 4 bytes
Below is my code to generate ASM for OnRightClick for 2.4.3
Code:
internal static string[] RightClick(uint guidAddr)
{
return new string[]
{
"mov eax, " + guidAddr,
"mov ecx, [eax + 4]",
"mov edx, [eax] ",
"push ecx",
"push edx",
"call 0x4A7980",
"add esp, 8",
"retn"
};
}
The parameter 'guidAddr' is a pointer(4 bytes) to 8 bytes of memory where the GUID is stored. So to break it down
1. I get a pointer (4 bytes) to your GUID (8 bytes)
2. I move the pointer(4 bytes) into eax
3. Read the value at eax +4 (the first 4 bytes of our GUID) and store into ecx
4. Read the value at eax (the last 4 bytes of our GUID) and store into edx
5. Push ecx (the first 4 bytes of our GUID)
6. Push eax (the last 4 bytes of our GUID)
Last edited by boipus; 04-18-2019 at 10:41 PM.
Reason: First post was wrong
-
Post Thanks / Like - 3 Thanks
-
Member
I've been puzzling for two days how to divide UInt64 into 2 UInt32 turned out to be so simple
very big thank you!!!
You my god))
-
Contributor
A bit simpler option:
Code:
internal static string[] RightClick(ulong guid)
{
var low = (uint)(guid & 0xFFFFFFFF);
var high = (uint)((guid >> 32) & 0xFFFFFFFF);
return new string[]
{
"push " + high,
"push " + low,
"call 0x4A7980", //int __cdecl CGGameUI::OnSpriteRightClick(__int64 guid)
"add esp, 8",
"retn"
};
}
Here the dividing ulong into two uints SO link.
Last edited by tutrakan; 04-22-2019 at 12:40 PM.