Closed colejohnson66 closed 7 months ago
Our project recently upgraded from 0.2.188 to 0.3.49. In doing so, ReadFile and WriteFile were changed from taking a SafeHandle to a raw HANDLE.
ReadFile
WriteFile
SafeHandle
HANDLE
In 0.2.188, our invocation of ReadFile was:
if (PInvoke.ReadFile(_handle, ptr, (uint)buffer.Length, &bytesRead, overlapped)) return (int)bytesRead;
In 0.3.49, we are now forced to do the dance that CsWin32 would previously do for us:
bool addedRef = false; try { // extract a HANDLE from the SafeFileHandle _handle.DangerousAddRef(ref addedRef); if (PInvoke.ReadFile((HANDLE)_handle.DangerousGetHandle(), ptr, (uint)buffer.Length, &bytesRead, overlapped)) return (int)bytesRead; } finally { _handle.DangerousRelease(); }
net8.0
I see span overloads were added, so I will assume those are the recommended method of invocation now.
Our project recently upgraded from 0.2.188 to 0.3.49. In doing so,
ReadFile
andWriteFile
were changed from taking aSafeHandle
to a rawHANDLE
.In 0.2.188, our invocation of
ReadFile
was:In 0.3.49, we are now forced to do the dance that CsWin32 would previously do for us:
Context
net8.0