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

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlStringTable.cs
- CompositeControlDesigner.cs
- TypeSystem.cs
- XPathParser.cs
- TextRenderer.cs
- LogExtent.cs
- DesignerForm.cs
- RunWorkerCompletedEventArgs.cs
- ping.cs
- DecimalAnimation.cs
- ViewStateModeByIdAttribute.cs
- Fault.cs
- ConfigurationValidatorBase.cs
- WorkflowItemsPresenter.cs
- Environment.cs
- DataView.cs
- OutputCacheProfile.cs
- CodePageEncoding.cs
- Events.cs
- MapPathBasedVirtualPathProvider.cs
- CompoundFileReference.cs
- CodeConditionStatement.cs
- SocketAddress.cs
- MobileUserControl.cs
- CommandDesigner.cs
- XmlSchemaRedefine.cs
- hresults.cs
- LinqDataSourceStatusEventArgs.cs
- AuthorizationRule.cs
- UserInitiatedNavigationPermission.cs
- EndpointBehaviorElement.cs
- ExpressionNormalizer.cs
- ServiceAuthorizationElement.cs
- DataSourceXmlSerializationAttribute.cs
- SecurityDocument.cs
- followingsibling.cs
- XmlIlGenerator.cs
- ListViewGroupItemCollection.cs
- CriticalFileToken.cs
- QueryExpr.cs
- WebServiceData.cs
- ParameterDataSourceExpression.cs
- BitmapFrameEncode.cs
- ApplicationServicesHostFactory.cs
- ExceptionHandler.cs
- StringAnimationBase.cs
- FixedSchema.cs
- StateItem.cs
- ResumeStoryboard.cs
- PropertyPath.cs
- WebCategoryAttribute.cs
- ToolTipAutomationPeer.cs
- ResXResourceWriter.cs
- NumberSubstitution.cs
- OutputCacheSection.cs
- SystemEvents.cs
- DataBindingCollection.cs
- ImageSourceConverter.cs
- BinaryMethodMessage.cs
- SqlUdtInfo.cs
- TextEditorTyping.cs
- GridSplitterAutomationPeer.cs
- FreezableDefaultValueFactory.cs
- ListBoxDesigner.cs
- LinkDescriptor.cs
- ReturnEventArgs.cs
- UdpSocketReceiveManager.cs
- HybridWebProxyFinder.cs
- AnnotationAuthorChangedEventArgs.cs
- CommandValueSerializer.cs
- ExpandedProjectionNode.cs
- reliableinputsessionchannel.cs
- TextEditorTables.cs
- MultiAsyncResult.cs
- RequestResizeEvent.cs
- SourceLineInfo.cs
- TypedReference.cs
- HostVisual.cs
- SoapFault.cs
- WindowsTokenRoleProvider.cs
- KnownBoxes.cs
- ServicePoint.cs
- X500Name.cs
- ExpressionEditor.cs
- LocatorPartList.cs
- TypedTableBase.cs
- StoreContentChangedEventArgs.cs
- SurrogateEncoder.cs
- DataRelationCollection.cs
- CapacityStreamGeometryContext.cs
- AssemblyResolver.cs
- XmlText.cs
- DataGridViewDataErrorEventArgs.cs
- WorkflowMarkupSerializer.cs
- NumericPagerField.cs
- EntityTypeBase.cs
- QilInvokeLateBound.cs
- Environment.cs
- XmlHelper.cs
- SecurityException.cs