External interface to a phandle

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

External interface to a phandle

John Small
Hi,

I'm trying to add a loose method to the kernal library for

    BOOL CreatePipe(
      PHANDLE hReadPipe,                       // pointer to read handle
      PHANDLE hWritePipe,                      // pointer to write handle
      LPSECURITY_ATTRIBUTES         lpPipeAttributes,  // pointer to
security attributes
      DWORD nSize                              // pipe size
    );

But I'm confused about what to do about PHANDLE.

The createPipe function needs to write handles into the hReadPipe and
hWritePipe
address locations.

How can this be done?

John


Reply | Threaded
Open this post in threaded view
|

Re: External interface to a phandle

Ian Bartholomew-16
John,

> How can this be done?

I had a quick browse on MSDN and cam up with the following. It appears to
work, the api call answers true and the read/write values appear to be
initialised, but you'll have to do further testing to see if they are valid
and usable

KernelLibrary>>createPipe: hReadPipe hWritePipe: hWritePipe
lpPipeAttributes: lpPipeAttributes nSize: nSize
    "BOOL CreatePipe(
        PHANDLE hReadPipe, // read handle
        PHANDLE hWritePipe, // write handle
        LPSECURITY_ATTRIBUTES lpPipeAttributes, // security attributes
        DWORD nSize // pipe size );"
    <stdcall: bool CreatePipe dword dword lpvoid dword>
    ^self invalidCall

Evaluate the following in a workspace to test

read := DWORD new.
write := DWORD new.
KernelLibrary default
    createPipe: read yourAddress
    hWritePipe: write yourAddress
    lpPipeAttributes: nil
    nSize: 0.

write value ==> handle
read value ==> handle

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: External interface to a phandle

Blair McGlashan
In reply to this post by John Small
"John Small" <[hidden email]> wrote in message
news:[hidden email]...
> Hi,
>
> I'm trying to add a loose method to the kernal library for [CreatePipe]

!KernelLibrary methodsFor!

createPipe: hReadPipe hWritePipe: hWritePipe lpPipeAttributes:
lpPipeAttributes nSize: nSize
 <stdcall: bool CreatePipe handle* handle* lpvoid dword>
 ^self invalidCall

 "
 hRead := ExternalHandle new.
 hWrite := ExternalHandle new.
 KernelLibrary default
  createPipe: hRead
  hWritePipe: hWrite
  lpPipeAttributes: nil
  nSize: 0
 "! !
!KernelLibrary categoriesFor:
#createPipe:hWritePipe:lpPipeAttributes:nSize:!public!win32 functions-pipe!
!

>
> But I'm confused about what to do about PHANDLE.
>
> The createPipe function needs to write handles into the hReadPipe and
> hWritePipe
> address locations.
>
> How can this be done?

The VM will automatically coerce the object passed depending on the argument
type, in the case of pointer arguments this usually means passing the
address of the bytes of the object (assuming it is a byte object). For
further information see:

http://www.object-arts.com/Lib/EducationCentre4/htm/externalinterfacing.htm

and specifically:

http://www.object-arts.com/Lib/EducationCentre4/htm/parametertypes.validatio
nandconversion.htm

Regards

Blair