FFI, the Squeak Foreign Function Interface, is used to call functions located in shared libraries that are not part of the Squeak VM nor its plugins. It also provides means to read and write memory structures that are associated with the use of those shared libraries. A typical use is to directly invoke operating system APIs. As such, applications that use FFI can only be used on the platform(s) that support the particular API being used. C conventions are used throughout, though the external function could have been written by any language capable of generating object code that follows C conventions.
Technically what happens is you define what the interface is, the parameters, types etc. Then when you make the call, the FFI logic assembles the data from the Squeak Objects into the proper structures according to the routine calling conventions for your architecture, and of course manages the return values. So no magic but perhaps just a little assembler in the plugin to properly deal with all the registers and condition flags.
For macs search Apple's web site for "Mac OS Runtime Architectures"
FFI is probably the easiest way to do the things it does, but it does have limitations...
Why might I not want to use FFI?
FFI is dangerous, slow, and platform-specific. See FFI Caveats for details.