Jump to content
Moopler
Raymond

Question [GMS] converting teleport crashes

Recommended Posts

CE Scripts works good: 

[ENABLE]
alloc(Teleport,128)
CreateThread(Teleport)

Teleport:
mov esi,[020BFCDC] // CUserLocal: 8B 3D ? ? ? ? 8B 40
push #0 // Y
push #0 // X
push [esi+5F94] // Character PID: 8B 86 ? ? 00 00 6A D8
call 017BC640 // CUserLocal__IsTeleportSkillAvailable: E8 ? ? ? ? 8D ? ? ? ? ? ? ? 89 ? ? ? ? ? E8 ? ? ? ? DB [FUNCTION START] (push esi)
ret

[DISABLE]
dealloc(Teleport)

 

My try at converting failed:

typedef void (__fastcall* CUserLocal__IsTeleportSkillAvailable_t)(void* lpvEcx, void* lpvEdx, void* lpvPID, int X, int Y);
CUserLocal__IsTeleportSkillAvailable_t CUserLocal__IsTeleportSkillAvailable = reinterpret_cast<CUserLocal__IsTeleportSkillAvailable_t>(0x017BC640);

void Teleport(int X, int Y)
{
	void* lpvBase = *reinterpret_cast<void**>(0x020BFCDC);
	void* lpvPID = reinterpret_cast<unsigned char*>(lpvBase) + 0x5F94;

	return CUserLocal__IsTeleportSkillAvailable(NULL, NULL, lpvPID, X, Y);
}

help me plz

Share this post


Link to post

Disclaimer:

I can't code.

 

according to IDA:

int __thiscall CUserLocal__IsTeleportSkillAvailable(CUserLocal *this, SKILLENTRY *pSkill, int nSLV, tagPOINT *ptAfterTeleport)

return CUserLocal__IsTeleportSkillAvailable(NULL, NULL, 

 

pass *this(that's the CUserLocal base) and void* pSkill to your function.

 

or do something like this:

LPBYTE CUserLocal__IsTeleportSkillAvailable = reinterpret_cast<LPBYTE>(0x017BC640);
void __declspec(naked) Teleport(int x, int y)
{
	__asm
	{
		mov esi,[0x020BFCDC] // CUserLocal: 8B 3D ? ? ? ? 8B 40
		push y
		push x
		push [esi+0x5F94] // Character PID: 8B 86 ? ? 00 00 6A D8
		call CUserLocal__IsTeleportSkillAvailable //E8 ? ? ? ? 8D ? ? ? ? ? ? ? 89 ? ? ? ? ? E8 ? ? ? ? DB [FUNCTION START] (push esi)
	}
}

and just call Teleport()

Edited by DAVHEED

Share this post


Link to post

I think your calling convention is wrong. As you can see in the AA script the base class gets moved into the esi register, as to where you don't use that anywhere in your call to CUserLocal__IsTeleportSkillAvailable.

Share this post


Link to post

If ESI was designed for use within the function, this would not be an official calling convention, would probably be the result of whole program optimization or link time code generation.

Options one would have in that case is to use assembly or watcom like compiler.

 

Edited by Taku

Share this post


Link to post
Guest

Plebsquad to the rescue :troll:

Ignore all previous answers, you simply forgot to take the value of lpvPid. You're passing a pointer to lpvPid, not the value.

 

Edited by Sprux

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×