internal unsafe void Reset(uint size) { if (size != this.m_Size) { if (this.m_Size != 0) { Overlapped.Free(this.m_pOverlapped); } this.m_Size = size; if (size == 0) { this.m_pOverlapped = null; this.m_MemoryBlob = null; this.m_BackingBuffer = null; } else { this.m_BackingBuffer = new byte[size]; this.m_pOverlapped = new Overlapped { AsyncResult = this }.Pack(s_IOCallback, this.m_BackingBuffer); this.m_MemoryBlob = (UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO *)Marshal.UnsafeAddrOfPinnedArrayElement(this.m_BackingBuffer, 0); } } }
protected override unsafe void OnReleasePins() { if (this.m_NativeOverlapped != null) { System.Threading.NativeOverlapped *nativeOverlapped = this.m_NativeOverlapped; this.m_NativeOverlapped = null; Overlapped.Free(nativeOverlapped); } }
protected override unsafe void OnReleasePins() { if (this.m_NativeOverlapped != null) { System.Threading.NativeOverlapped* nativeOverlapped = this.m_NativeOverlapped; this.m_NativeOverlapped = null; Overlapped.Free(nativeOverlapped); } }
protected override unsafe void Cleanup() { if (this.m_pOverlapped != null) { this.m_MemoryBlob = null; Overlapped.Free(this.m_pOverlapped); this.m_pOverlapped = null; } GC.SuppressFinalize(this); base.Cleanup(); }
private static unsafe void CompleteCallback(uint error, uint numBytes, System.Threading.NativeOverlapped *nativeOverlapped) { OverlappedContext thisHolder = ((RootedHolder)Overlapped.Unpack(nativeOverlapped).AsyncResult).ThisHolder; thisHolder.rootedHolder.ThisHolder = null; thisHolder.bufferPtr = null; thisHolder.bufferHolder[0] = dummyBuffer; OverlappedIOCompleteCallback pendingCallback = thisHolder.pendingCallback; thisHolder.pendingCallback = null; pendingCallback(true, (int)error, (int)numBytes); }
private unsafe UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST* Allocate(uint size) { uint num = (size != 0) ? size : ((base.RequestBuffer == null) ? 0x1000 : base.Size); if ((this.m_NativeOverlapped != null) && (num != base.RequestBuffer.Length)) { System.Threading.NativeOverlapped* nativeOverlapped = this.m_NativeOverlapped; this.m_NativeOverlapped = null; Overlapped.Free(nativeOverlapped); } if (this.m_NativeOverlapped == null) { base.SetBuffer((int) num); this.m_NativeOverlapped = new Overlapped { AsyncResult = this.m_Result }.Pack(ListenerAsyncResult.IOCallback, base.RequestBuffer); return (UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST*) Marshal.UnsafeAddrOfPinnedArrayElement(base.RequestBuffer, 0); } return base.RequestBlob; }
private unsafe UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST *Allocate(uint size) { uint num = (size != 0) ? size : ((base.RequestBuffer == null) ? 0x1000 : base.Size); if ((this.m_NativeOverlapped != null) && (num != base.RequestBuffer.Length)) { System.Threading.NativeOverlapped *nativeOverlapped = this.m_NativeOverlapped; this.m_NativeOverlapped = null; Overlapped.Free(nativeOverlapped); } if (this.m_NativeOverlapped == null) { base.SetBuffer((int)num); this.m_NativeOverlapped = new Overlapped { AsyncResult = this.m_Result }.Pack(ListenerAsyncResult.IOCallback, base.RequestBuffer); return((UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST *)Marshal.UnsafeAddrOfPinnedArrayElement(base.RequestBuffer, 0)); } return(base.RequestBlob); }
public unsafe OverlappedContext() { if (completeCallback == null) { completeCallback = Fx.ThunkCallback(new IOCompletionCallback(OverlappedContext.CompleteCallback)); } if (eventCallback == null) { eventCallback = Fx.ThunkCallback(new WaitOrTimerCallback(OverlappedContext.EventCallback)); } if (cleanupCallback == null) { cleanupCallback = Fx.ThunkCallback(new WaitOrTimerCallback(OverlappedContext.CleanupCallback)); } this.bufferHolder = new object[] { dummyBuffer }; this.overlapped = new Overlapped(); this.nativeOverlapped = this.overlapped.UnsafePack(completeCallback, this.bufferHolder); this.pinnedHandle = GCHandle.FromIntPtr(*((IntPtr *)(this.nativeOverlapped + (((IntPtr.Size == 4) ? -4 : -3) * sizeof(IntPtr))))); this.pinnedTarget = this.pinnedHandle.Target; this.rootedHolder = new RootedHolder(); this.overlapped.AsyncResult = this.rootedHolder; }
public unsafe OverlappedContext() { if (completeCallback == null) { completeCallback = Fx.ThunkCallback(new IOCompletionCallback(OverlappedContext.CompleteCallback)); } if (eventCallback == null) { eventCallback = Fx.ThunkCallback(new WaitOrTimerCallback(OverlappedContext.EventCallback)); } if (cleanupCallback == null) { cleanupCallback = Fx.ThunkCallback(new WaitOrTimerCallback(OverlappedContext.CleanupCallback)); } this.bufferHolder = new object[] { dummyBuffer }; this.overlapped = new Overlapped(); this.nativeOverlapped = this.overlapped.UnsafePack(completeCallback, this.bufferHolder); this.pinnedHandle = GCHandle.FromIntPtr(*((IntPtr*) (this.nativeOverlapped + (((IntPtr.Size == 4) ? -4 : -3) * sizeof(IntPtr))))); this.pinnedTarget = this.pinnedHandle.Target; this.rootedHolder = new RootedHolder(); this.overlapped.AsyncResult = this.rootedHolder; }
internal unsafe void Reset(uint size) { if (size != this.m_Size) { if (this.m_Size != 0) { Overlapped.Free(this.m_pOverlapped); } this.m_Size = size; if (size == 0) { this.m_pOverlapped = null; this.m_MemoryBlob = null; this.m_BackingBuffer = null; } else { this.m_BackingBuffer = new byte[size]; this.m_pOverlapped = new Overlapped { AsyncResult = this }.Pack(s_IOCallback, this.m_BackingBuffer); this.m_MemoryBlob = (UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO*) Marshal.UnsafeAddrOfPinnedArrayElement(this.m_BackingBuffer, 0); } } }
public unsafe void Free() { if (this.pendingCallback != null) { throw Fx.AssertAndThrow("OverlappedContext.Free called while async operation is pending."); } if (this.syncOperationPending) { throw Fx.AssertAndThrow("OverlappedContext.Free called while sync operation is pending."); } if (this.nativeOverlapped == null) { throw Fx.AssertAndThrow("OverlappedContext.Free called multiple times."); } this.pinnedTarget = null; System.Threading.NativeOverlapped *nativeOverlapped = this.nativeOverlapped; this.nativeOverlapped = null; Overlapped.Free(nativeOverlapped); if (this.completionEvent != null) { this.completionEvent.Close(); } GC.SuppressFinalize(this); }
public unsafe static object GetNativeOverlappedState(System.Threading.NativeOverlapped *overlapped) { throw null; }
public unsafe void FreeNativeOverlapped(System.Threading.NativeOverlapped *overlapped) { }
private static unsafe void WaitCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped *nativeOverlapped) { ListenerClientCertAsyncResult asyncResult = (ListenerClientCertAsyncResult)Overlapped.Unpack(nativeOverlapped).AsyncResult; HttpListenerRequest asyncObject = (HttpListenerRequest)asyncResult.AsyncObject; object result = null; try { if (errorCode == 0xea) { UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO *requestBlob = asyncResult.RequestBlob; asyncResult.Reset(numBytes + requestBlob->CertEncodedSize); uint pBytesReceived = 0; errorCode = UnsafeNclNativeMethods.HttpApi.HttpReceiveClientCertificate(asyncObject.HttpListenerContext.RequestQueueHandle, asyncObject.m_ConnectionId, 0, asyncResult.m_MemoryBlob, asyncResult.m_Size, &pBytesReceived, asyncResult.m_pOverlapped); if ((errorCode == 0x3e5) || (errorCode == 0)) { return; } } if (errorCode != 0) { asyncResult.ErrorCode = (int)errorCode; result = new HttpListenerException((int)errorCode); } else { UnsafeNclNativeMethods.HttpApi.HTTP_SSL_CLIENT_CERT_INFO *memoryBlob = asyncResult.m_MemoryBlob; if (memoryBlob != null) { if (memoryBlob->pCertEncoded != null) { try { byte[] destination = new byte[memoryBlob->CertEncodedSize]; Marshal.Copy((IntPtr)memoryBlob->pCertEncoded, destination, 0, destination.Length); result = asyncObject.ClientCertificate = new X509Certificate2(destination); } catch (CryptographicException exception) { result = exception; } catch (SecurityException exception2) { result = exception2; } } asyncObject.SetClientCertificateError((int)memoryBlob->CertFlags); } } } catch (Exception exception3) { if (NclUtilities.IsFatal(exception3)) { throw; } result = exception3; } finally { if (errorCode != 0x3e5) { asyncObject.ClientCertState = ListenerClientCertState.Completed; } } asyncResult.InvokeCallback(result); }
internal unsafe DisconnectAsyncResult(HttpListener httpListener, ulong connectionId) { this.m_HttpListener = httpListener; this.m_ConnectionId = connectionId; this.m_NativeOverlapped = new Overlapped { AsyncResult = this }.UnsafePack(s_IOCallback, null); }
public unsafe void Free() { if (this.pendingCallback != null) { throw Fx.AssertAndThrow("OverlappedContext.Free called while async operation is pending."); } if (this.syncOperationPending) { throw Fx.AssertAndThrow("OverlappedContext.Free called while sync operation is pending."); } if (this.nativeOverlapped == null) { throw Fx.AssertAndThrow("OverlappedContext.Free called multiple times."); } this.pinnedTarget = null; System.Threading.NativeOverlapped* nativeOverlapped = this.nativeOverlapped; this.nativeOverlapped = null; Overlapped.Free(nativeOverlapped); if (this.completionEvent != null) { this.completionEvent.Close(); } GC.SuppressFinalize(this); }