Passing a variable as a pointer to a windows DLL method

hi guys,

i’m having a problem with a DLL method call which requires a few
pointers.
the code is seg faulting (on the openPort call), so any advice is
appreciated.

i’ve been able to call other methods from the same dll, so it’s possible
i’m passing the variables incorrectly to this method.

require ‘dl’

$my_dll = DL.dlopen(‘some.dll’)

handle = " " * 4
p_mask = " " * 8
$my_dll[‘openPort’, ‘HicIiIII’].call(handle, “demo”, a_mask, p_mask,
1024, 3, 2)

Note, a_mask is initialised elsewhere.

The openPort method has the following signature:

openPort (
long *pHandle,
char *userName,
unsigned __int64 accessMask,
unsigned __int64 *pPermissionMask,
unsigned int queueSize,
unsigned int version,
unsigned int type)
);

I’ve also tried using the Win32API library, with the same result:

require “Win32API”
mydll = “some.dll”

openport =
Win32API.new(mydll,“openPort”,[‘P’,‘P’,‘I’,‘P’,‘I’,‘I’,‘I’],‘I’)
openport.call(handle, “demo”, a_mask, p_mask, 1024, 3, 2)

thanks in advance…