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
2000748544
> (define proc (dlsym lib "malloc"))
> proc
2000788909
> (define malloc (malloc-sig proc))
> malloc
#<procedure ffi-callout>
> (define mem (malloc 8))
> mem
1905864
>
Advertisements

Responses

  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:

WordPress.com Logo

You are commenting using your WordPress.com 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

Categories

%d bloggers like this: