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
>


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 response

Your response:

Categories