 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
efjay Newbie cheater
Reputation: 0
Joined: 17 Apr 2014 Posts: 12
|
Posted: Fri Sep 25, 2015 9:11 am Post subject: calling a function in lua engine |
|
|
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 |
|
 |
Redouane Master Cheater
Reputation: 3
Joined: 05 Sep 2013 Posts: 363 Location: Algeria
|
Posted: Fri Sep 25, 2015 9:32 am Post subject: Re: calling a function in lua engine |
|
|
| 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 |
|
 |
efjay Newbie cheater
Reputation: 0
Joined: 17 Apr 2014 Posts: 12
|
Posted: Fri Sep 25, 2015 10:28 am Post subject: Re: calling a function in lua engine |
|
|
| 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 |
|
 |
Redouane Master Cheater
Reputation: 3
Joined: 05 Sep 2013 Posts: 363 Location: Algeria
|
Posted: Fri Sep 25, 2015 3:46 pm Post subject: Re: calling a function in lua engine |
|
|
| 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 |
|
 |
|
|
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
|
|