Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


calling a function in lua engine

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
efjay
Newbie cheater
Reputation: 0

Joined: 17 Apr 2014
Posts: 12

PostPosted: Fri Sep 25, 2015 9:11 am    Post subject: calling a function in lua engine Reply with quote

Hi. If I want to call, say ws2_32.send from my lua script, do I have to use auto assembly?

I am quite noob at ASM.. still learning, but do I do something like this inside lua
Code:

   autoAssemble(
      "globalalloc(RegSend, 1024)\n" ..
      "RegSend:\n" ..
      "push 0\n" ..
      "push 10\n" ..
      "push FFFFFFFFFF\n" ..
      "push " .. tostring( sendSocket ) .. "\n" ..
      "call ws2_32.send" ..
      "ret\n"
   );


Then to run it
Code:

autoAssemble( "CreateThread(RegSend)\n" );

?

Thanks for input.
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Fri Sep 25, 2015 9:32 am    Post subject: Re: calling a function in lua engine Reply with quote

efjay wrote:
Hi. If I want to call, say ws2_32.send from my lua script, do I have to use auto assembly?


Code:
autoAssemble(string.format([[
globalalloc(RegSend, 1024)
RegSend:
push 0
push 10
push FFFFFFFFFF
push %s
call ws2_32.send
ret
registersymbol(RegSend)]],tostring( sendSocket ))
);

To call:
Code:
createthread(RegSend)
Back to top
View user's profile Send private message
efjay
Newbie cheater
Reputation: 0

Joined: 17 Apr 2014
Posts: 12

PostPosted: Fri Sep 25, 2015 10:28 am    Post subject: Re: calling a function in lua engine Reply with quote

Redouane wrote:
efjay wrote:
Hi. If I want to call, say ws2_32.send from my lua script, do I have to use auto assembly?


Code:
autoAssemble(string.format([[
globalalloc(RegSend, 1024)
RegSend:
push 0
push 10
push FFFFFFFFFF
push %s
call ws2_32.send
ret
registersymbol(RegSend)]],tostring( sendSocket ))
);

To call:
Code:
createthread(RegSend)


Alright, so that's quite similar to what I had, good!

So the MSDN says
int send(
_In_ SOCKET s,
_In_ const char *buf,
_In_ int len,
_In_ int flags
);

is it proper how i have flags first, then length, then buffer? or should it be the other order for pushing?
Back to top
View user's profile Send private message
Redouane
Master Cheater
Reputation: 3

Joined: 05 Sep 2013
Posts: 363
Location: Algeria

PostPosted: Fri Sep 25, 2015 3:46 pm    Post subject: Re: calling a function in lua engine Reply with quote

efjay wrote:
Redouane wrote:
efjay wrote:
Hi. If I want to call, say ws2_32.send from my lua script, do I have to use auto assembly?


Code:
autoAssemble(string.format([[
globalalloc(RegSend, 1024)
RegSend:
push 0
push 10
push FFFFFFFFFF
push %s
call ws2_32.send
ret
registersymbol(RegSend)]],tostring( sendSocket ))
);

To call:
Code:
createthread(RegSend)


Alright, so that's quite similar to what I had, good!

So the MSDN says
int send(
_In_ SOCKET s,
_In_ const char *buf,
_In_ int len,
_In_ int flags
);

is it proper how i have flags first, then length, then buffer? or should it be the other order for pushing?


I think that you are doing it right,you push the arguments in the reverse order,
Code:
f(int a,int b,int c)

becomes
Code:
push c
push b
push a
call address_where_f_begins

in the call (before any stackframe),[esp+4] should contain the first arg (a),[esp+8] -> b,and [esp+0c] -> c
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites