More FFI Help with long buffers

Andreas Raab andreas.raab at gmx.de
Tue Aug 8 00:51:52 UTC 2006


I might be able to help you if instead of describing your attempted 
solutions you'd spend a paragraph or two on describing the problem. "I 
need to send in a long value as a buffer" isn't even remotely enough 
information to give any useful advice.

Cheers,
   - Andreas

Ron Teitelbaum wrote:
> Hello all,
> 
> I've been having some trouble with an api call.  I need to send in a long
> value as a buffer.  
> 
> I've tried a few things.
> 1: just using an external address allocated to 4 bytes using an integer
> address.
> 
> MyExtFunc >> withBuffer: aBuffer
> 
> <apicall: bool 'MyAPICall' (long) module: 'my.dll'>
> 
> ------------------
> 
> MyExtFunc >> callWithBuffer
> 
> aBuffer := ExternalAddress allocate: 4.
> 
> self withBuffer: aBuffer getHandle asInteger.
> 
> -------------------
> 
> 2: Using a pointer to ExternalAddress
> MyExtFunc >> withBuffer: aBuffer
> 
> <apicall: bool 'MyAPICall' (ExternalAddress*) module: 'my.dll'>
> 
> --------------------
> 
> MyExtFunc >> callWithBuffer
> 
> aBuffer := ExternalAddress allocate: 4.
> 
> self withBuffer: aBuffer
> 
> -------------------
> 3: Creating external structure that holds a long 
> 
> MyExtFunc >> withBuffer: aBuffer
> 
> <apicall: bool 'MyAPICall' (Win32LongBuffer*) module: 'my.dll'>
> 
> -------------------
> 
> MyExtFunc >> callWithBuffer
> 
> aBuffer := Win32LongBuffer new buffer: 0; yourself
> aBuffer setHandle: (ExternalAddress allocate: 4).
> 
> self withBuffer: aBuffer
> 
> 
> -------------------
> 4: I tried the Win32LongBuffer as (long) with aBuffer getHandle asInteger
> -------------------
> 5: I tried ExternalData using Cees method: 
> 
> argBuf _ ByteArray new: 4.
> argBuf longAt: 1 put: 0 bigEndian: false.
> argPtr _ ExternalData fromHandle: argBuf type: ExternalType long
> asPointerType.
> 
> -------------------
> 6: extData := ExternalData fromHandle: (ptr := ExternalAddress allocate: 4)
> type: ExternalType long [asPointerType]
> 
> Sending in the handle of the extData or the ptr and I tried both as integer.
> 
> 
> So far nothing is working.  I believe that the problem is the buffer.  Does
> anyone have any suggestions of other things I could try?
> 
> The Error I'm receiving is consistent: 
> //
> // MessageId: ERROR_ALREADY_EXISTS
> //
> // MessageText:
> //
> //  Cannot create a file when that file already exists.
> //
> #define ERROR_ALREADY_EXISTS             183L
> 
> I'm not sure what that means.  Googleing it didn't help much.
> 
> Does anyone have some suggestions on how to send in a long buffer for the
> api to fill?
> 
> Any help would be greatly appreciated!
> 
> Thanks,
> 
> Ron Teitelbaum
> 
> 
> 




More information about the Squeak-dev mailing list