Problem - Inline Assembly Call Function

04/27/2014 08:07 -Zynel*#1
Old Client Function:

Code:
00414710 - push ecx
00414711 - mov ecx,[esp+0C]
00414715 - lea eax,[esp]
00414718 - push eax
00414719 - push 00
0041471B - push ecx
0041471C - call 00520550
00414721 - add esp,0C
00414724 - test al,al
00414726 - jne 00414734
00414728 - push 00
0041472A - call 00520640
0041472F - add esp,04
00414732 - pop ecx
00414733 - ret 
00414734 - mov edx,[esp]
00414737 - mov ecx,[0061C028] : [1F708A70]
0041473D - push edx
0041473E - call 0041F000
00414743 - call 005204C0
00414748 - pop ecx
My inline assembly code in c++:

Code:
void InlineASM(int arg)
{
     DWORD calladr = 0x0041F000;
     __asm{
          MOV EDX, 0x0061C028
          MOV ECX, DWORD PTR DS:[EDX]
          PUSH arg
          CALL calladr
     }
}
And It's working.



But in new client function:

Code:
004B1A10 - push ecx
004B1A11 - push esi
004B1A12 - mov esi,[esp+10]
004B1A16 - mov eax,0000FFFF
004B1A1B - push esi
004B1A1C - mov byte ptr [esp+08],01
004B1A21 - mov [esp+09],ax
004B1A26 - call dword ptr [00E3D824]
004B1A2C - add esp,04
004B1A2F - sub eax,01
004B1A32 - je 004B1A55
004B1A34 - sub eax,01
004B1A37 - jne 004B1A69
004B1A39 - lea ecx,[esp+04]
004B1A3D - push ecx
004B1A3E - push eax
004B1A3F - push esi
004B1A40 - call 0054EE80
004B1A45 - add esp,0C
004B1A48 - test al,al
004B1A4A - je 004B1A69
004B1A4C - lea edx,[esp+05]
004B1A50 - push edx
004B1A51 - push 01
004B1A53 - jmp 004B1A5C
004B1A55 - lea eax,[esp+05]
004B1A59 - push eax
004B1A5A - push 00
004B1A5C - push esi
004B1A5D - call 0054EEB0
004B1A62 - add esp,0C
004B1A65 - test al,al
004B1A67 - jne 004B1A76
004B1A69 - push 00
004B1A6B - call 0054EE10
004B1A70 - add esp,04
004B1A73 - pop esi
004B1A74 - pop ecx
004B1A75 - ret 
004B1A76 - mov dl,[esp+06]
004B1A7A - push ecx
004B1A7B - mov cx,[esp+08]
004B1A80 - mov eax,esp
004B1A82 - mov [eax],cx
004B1A85 - mov ecx,[00FFE7AC] : [00000000]
004B1A8B - mov [eax+02],dl
004B1A8E - call 004BD540
004B1A93 - call 008A4040
004B1A98 - pop esi
004B1A99 - pop ecx
004B1A9A - ret
I was trying work with new client function, doesn't work.

How to use new client function in inline assembly?

Thanks for helps.
04/27/2014 10:39 ​Tension#2
Are you sure it's the correct function?
04/27/2014 10:52 -Zynel*#3
Quote:
Originally Posted by ​Tension View Post
Are you sure it's the correct function?
Yes.

"SendItemUsePacket" in metin2.
04/27/2014 11:37 ​Tension#4
if you just want to call the function then your previous code should work since the parameter didn't changed. Do you want to call the function 0x004B1A10? Or Is the SendItemUsePacket function in that function?

Code:
bool SendItemUsePacket(BYTE ItemPos)
{
	typedef bool pSendItemUsePacket(BYTE Pos);
	pSendItemUsePacket* rSendItemUsePacket = (pSendItemUsePacket*)0x004B1A10;
	return rSendItemUsePacket(ItemPos);
}
should probably work too.

Inline ASM:
Code:
bool SendItemUsePacket(BYTE ItemPos)
{
	bool rval = false;
	DWORD call_addr = 0x004B1A10;
	_asm
	{
		push ItemPos
		call call_addr
		mov rval, eax	//Store the return value in rval
	}
	return rval;
}
04/27/2014 12:03 -Zynel*#5
Quote:
Originally Posted by ​Tension View Post
if you just want to call the function then your previous code should work since the parameter didn't changed. Do you want to call the function 0x004B1A10? Or Is the SendItemUsePacket function in that function?

Code:
bool SendItemUsePacket(BYTE ItemPos)
{
	typedef bool pSendItemUsePacket(BYTE Pos);
	pSendItemUsePacket* rSendItemUsePacket = (pSendItemUsePacket*)0x004B1A10;
	return rSendItemUsePacket(ItemPos);
}
should probably work too.

Inline ASM:
Code:
bool SendItemUsePacket(BYTE ItemPos)
{
	bool rval = false;
	DWORD call_addr = 0x004B1A10;
	_asm
	{
		push ItemPos
		call call_addr
		mov rval, eax	//Store the return value in rval
	}
	return rval;
}
I will try, thanks :)

And SendItemUsePacket function is in that function.

Doesn't working with 0x004B1A10 func.

I need same as

Code:
void InlineASM(int arg)
{
     DWORD calladr = 0x0041F000;
     __asm{
          MOV EDX, 0x0061C028
          MOV ECX, DWORD PTR DS:[EDX]
          PUSH arg
          CALL calladr
     }
}
04/28/2014 23:10 wurstbrot123#6
Code:
void InlineASM(int arg)
{
     DWORD calladr = 0x004BD540;
     __asm{
          MOV EDX, 0x00FFE7AC
          MOV ECX, DWORD PTR DS:[EDX]
          PUSH arg
          CALL calladr
     }
}
try this
04/29/2014 12:58 MrSm!th#7
Use function pointers.
04/29/2014 13:42 -Zynel*#8
Quote:
Originally Posted by wurstbrot123 View Post
Code:
void InlineASM(int arg)
{
     DWORD calladr = 0x004BD540;
     __asm{
          MOV EDX, 0x00FFE7AC
          MOV ECX, DWORD PTR DS:[EDX]
          PUSH arg
          CALL calladr
     }
}
try this
I tried first this but it doesn't work :)

Quote:
Originally Posted by MrSm!th View Post
Use function pointers.
Have you example? :)
04/30/2014 11:43 Tyrar#9
Code:
void(*pFunc)(int) = (void(*)(int))0x11111111;
pFunc(param);
05/24/2014 17:15 -Zynel*#10
I tried all but doesn't work :D I think need to use asm.