Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / SafeLocalAllocation.cs / 1305376 / SafeLocalAllocation.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.Tools.ServiceModel.WsatConfig { using System; using System.Security; using System.Security.Permissions; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; using Microsoft.Win32.SafeHandles; sealed class SafeLocalAllocation : SafeHandleZeroOrMinusOneIsInvalid { [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] internal SafeLocalAllocation(int size) : base(true) { #pragma warning suppress 56523 IntPtr pointer = SafeNativeMethods.LocalAlloc(SafeNativeMethods.LMEM_ZEROINIT, size); SetHandle(pointer); } #if WSAT_UI [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] internal SafeLocalAllocation(object source) : base(true) { #pragma warning suppress 56523 IntPtr pointer = SafeNativeMethods.LocalAlloc(SafeNativeMethods.LMEM_ZEROINIT, Marshal.SizeOf(source)); SetHandle(pointer); Marshal.StructureToPtr( source, handle, false); } #endif internal void Copy(byte[] source, int startIndex, int count) { System.Runtime.InteropServices.Marshal.Copy( source, startIndex, handle, count); } protected override bool ReleaseHandle() { #pragma warning suppress 56523 IntPtr r = SafeNativeMethods.LocalFree(handle); return r == IntPtr.Zero; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RawStylusInput.cs
- DelimitedListTraceListener.cs
- ApplicationException.cs
- ParagraphResult.cs
- TableItemPattern.cs
- DataSourceControlBuilder.cs
- QilSortKey.cs
- ConnectionStringsExpressionBuilder.cs
- EntityTransaction.cs
- AsyncSerializedWorker.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- OdbcInfoMessageEvent.cs
- CatalogZone.cs
- PageStatePersister.cs
- ConnectionsZone.cs
- NumericUpDownAcceleration.cs
- DataColumnCollection.cs
- EdmConstants.cs
- TransformDescriptor.cs
- ClientEventManager.cs
- SymbolTable.cs
- ProcessModule.cs
- OutputCacheModule.cs
- EntityDataSourceStatementEditor.cs
- BrushValueSerializer.cs
- ToolStripItemDataObject.cs
- MouseGesture.cs
- figurelengthconverter.cs
- ImageSourceConverter.cs
- XmlSchema.cs
- ValueUtilsSmi.cs
- QueryStringParameter.cs
- ZipFileInfo.cs
- ContractSearchPattern.cs
- SQLDouble.cs
- LicenseContext.cs
- ExpandedWrapper.cs
- TreeNode.cs
- AppDomainInfo.cs
- ListItemCollection.cs
- DataGridViewCellStyleConverter.cs
- RsaSecurityKey.cs
- EntityCommandExecutionException.cs
- MemberAccessException.cs
- TextRunTypographyProperties.cs
- DetailsViewDeleteEventArgs.cs
- ConstructorNeedsTagAttribute.cs
- TcpAppDomainProtocolHandler.cs
- webeventbuffer.cs
- _ListenerRequestStream.cs
- ActivityCodeDomSerializer.cs
- EventsTab.cs
- Events.cs
- PropertyEntry.cs
- GroupItem.cs
- PersonalizationEntry.cs
- SEHException.cs
- WebPartCloseVerb.cs
- IListConverters.cs
- SafeFileMapViewHandle.cs
- QueryConverter.cs
- DataGridTablesFactory.cs
- exports.cs
- TransportContext.cs
- CLSCompliantAttribute.cs
- WeakReferenceEnumerator.cs
- WsdlWriter.cs
- CachedFontFamily.cs
- DecoderExceptionFallback.cs
- ThreadPool.cs
- PageTrueTypeFont.cs
- SystemKeyConverter.cs
- Substitution.cs
- D3DImage.cs
- LinearKeyFrames.cs
- DefaultAssemblyResolver.cs
- LingerOption.cs
- ChtmlCommandAdapter.cs
- localization.cs
- QueryExpr.cs
- OleDbCommandBuilder.cs
- DataFormats.cs
- WebConfigurationFileMap.cs
- AccessDataSourceView.cs
- Polyline.cs
- EmptyControlCollection.cs
- PropertyDescriptor.cs
- Assert.cs
- _RequestCacheProtocol.cs
- PropertyPanel.cs
- MimeTypeMapper.cs
- Certificate.cs
- CellLabel.cs
- HMACMD5.cs
- PowerEase.cs
- HttpStreamMessageEncoderFactory.cs
- BufferBuilder.cs
- ScopelessEnumAttribute.cs
- DateTimeValueSerializerContext.cs
- JobPageOrder.cs