pinvoke icon indicating copy to clipboard operation
pinvoke copied to clipboard

Change CreatePipe to use SafeFileHandle instead of SafeObjectHandle

Open ZoeyR opened this issue 6 years ago • 3 comments

The CreatePipe method should output SafeFileHandles intead of SafeObjectHandles. By outputting SafeFileHandle directly it makes it easier to wrap these up in FileReader and FileWriter classes.

ZoeyR avatar Mar 29 '19 22:03 ZoeyR

There's a lot of Kernel32 which interop with files. Basically every first argument to a Kernel32 method which is named hFile or hDevice should be a SafeFileHandle instead.

It makes a lot of sense to change them all. @AArnott thoughts?

qmfrederik avatar Jul 06 '20 19:07 qmfrederik

I had similar thoughts to the OP's, only CreateFile was the API I cared about. Help me understand the thinking in returning SafeObjectHandle? None of the .NET FileStream constructors know what to do with that, but maybe you had a different .NET API in mind to interact with SafeObjectHandles?

blakegordon avatar Jan 26 '21 19:01 blakegordon

Probably not enough care in choosing it. I could see us unifying this.

AArnott avatar Jan 29 '21 05:01 AArnott