Posted by: leppie | January 21, 2009

I can has FFI (too)!


> (import (ironscheme clr))
> (define dlload (pinvoke-call kernel32 LoadLibrary intptr (string)))
> (define dlsym (pinvoke-call kernel32 GetProcAddress intptr (intptr string)))
> (define malloc-sig (ffi-callout void* (uint32)))
> (define lib (dlload "msvcrt"))
> lib
> (define proc (dlsym lib "malloc"))
> proc
> (define malloc (malloc-sig proc))
> malloc
#<procedure ffi-callout>
> (define mem (malloc 8))
> mem


  1. A title like that requires a suitably absurd image to go along with it. I suggest a cute puppy or kitten on which to display your message.

    FFI: awesome.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: