Results 1 to 4 of 4

Thread: if Simba was the chicken, what is the egg?

  1. #1
    Join Date
    Dec 2014
    Posts
    383
    Mentioned
    2 Post(s)
    Quoted
    206 Post(s)

    Default if Simba was the chicken, what is the egg?

    I've always been wondering, if Simba was the hatched egg with all the includes, what is the egg?

    what makes up the function for Mouse(x,y)?


    how does simba recognize the mouse function?

    I know there are many includes for simba, but where do those includes come from?
    and if they are from within Simba, what created those?

    where does it all start?

    are there hard-coded things for programming like X,Y are X,Y because they are X,Y?

    ( have absolutely no background in this field, just pure curiosity )

  2. #2
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Quote Originally Posted by theholyone View Post
    I've always been wondering, if Simba was the hatched egg with all the includes, what is the egg?

    what makes up the function for Mouse(x,y)?


    how does simba recognize the mouse function?

    I know there are many includes for simba, but where do those includes come from?
    and if they are from within Simba, what created those?

    where does it all start?

    are there hard-coded things for programming like X,Y are X,Y because they are X,Y?

    ( have absolutely no background in this field, just pure curiosity )
    First of all, you're basically asking for someone to tell you how an interpreter works. Not cool. Google is your friend too ya'know!

    But now I'm already here so let's try -_-

    Simba is based off of SCAR which was created by Katneiks, originally just as a pet-project until his main project AutoRune was detected and banned, at which point SCAR became a viable tool. SCAR was closed-source, and is still being developed today by a guy named Freddy1990. Simba spawned to create an open-source version of this platform.

    Simba has functions built into it. Since Simba is written in Delphi, so are the internal functions. These include all the functions that make up your standard Simba library. Such as (straight from Simba source code):

    Delphi Code:
    //procedure MoveMouse(X, Y: Integer);
    procedure TIOManager_Abstract_MoveMouse(const Params: PParamArray); lape_extdecl
      PIOManager_Abstract(Params^[0])^.MoveMouse(PInteger(Params^[1])^, PInteger(Params^[2])^);
    end;

    We can access all of the functions that were built into Simba by default. To add aditional functionality, either write a script, or write an include. A script has localized functions whereas an include has a scope of anywhere you want to include it.

    Many people used to write includes, now-aday's theres like 4-5 that are actually used.

    Quote Originally Posted by theholyone View Post
    are there hard-coded things for programming like X,Y are X,Y because they are X,Y?
    Of course not. X and Y are variables, they can represent anything. But the way you wrote that sentence was too damn price-less for me not to point out.


    EDIT:
    Just realized I didn't even cover interpretation. Yay - Go Me!

  3. #3
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by theholyone View Post
    Where does it all start?


    You have a function called SendInput in the Windows API (https://msdn.microsoft.com/en-us/lib...v=vs.85).aspx). This function is a UserMode function and when invoked, it sends the parameters to your mouse driver telling it where to move. The mouse driver tells the kernel where the mouse should be and everything else is irrelevant from there on.


    How is SendInput invoked from MoveMouse? Well things are invoked by instructions (Assembly/Machine Language). SendInput has the following signature:

    C Code:
    UINT __stdcall SendInput(UINT nInputs, LPINPUT pInputs, int cbSize);

    So what you have to do is (push each parameter onto the stack in reverse order first via assembly instructions/machine instructions and invoke the call instruction):

    ASM Code:
    mov rax, inputs  ;Inputs is the address of a structure (LPINPUT aka Long-Pointer to Input Structure). It moves into a register which is pushed later on.
    push cbSize
    push rax
    push nInputs
    call SendInput


    This is how a function is called at the lowest possible level. This is "Machine instructions". Your CPU sees this and executes each one. No explanation of how is needed because that's irrelevant (but just incase, it's interpreted in voltages).

    Samba developers know this so what they do is they parse the MoveMouse function. Store each parameter in a stack (the structure, not the memory). For each parameter on the stack they pop it off and write a push instruction for it. When the stack gets empty (no more parameters), they write a call instruction and make the memory executable with VirtualProtect (Windows) or MMap (OSX/Linux). This will execute the actual SendInput function and voila. Your mouse has moved.


    Nowadays no one likes to write assembly/machine language, so a library called LibFFI (https://en.wikipedia.org/wiki/Libffi) does it all for you and does most of it in C (A higher-level human readable language). This library handles the calling conventions like STDCALL, FASTCALL, THISCALL, CDECL, PASCAL, etc.. This means that the library knows what order to push the instructions (STDCALL for reverse order) or whether or not the function belongs to a class (THISCALL), etc.. It also handles x86 and ARM instructions (different CPU architectures).

    With this library it's simple. Samba does: Invoke(&SendInput, ....) where ... are the parameters to SendInput and may or may not be a variadic parameter pack (a function accepting any amount parameters).

    With this, the developer does not have to know anything about the CPU or Assembly. The developer only needs to know the calling convention, the name of the function to be called (or address of it) and the parameters.

    From there on, everything is trivial.
    Last edited by Brandon; 02-14-2016 at 05:46 PM.
    I am Ggzz..
    Hackintosher

  4. #4
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    ...
    Today you learned Simba uses SetCursorPos to move the mouse!

    Nice explanation though.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •