Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / SafeLocalAllocation.cs / 1 / 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. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- VisualCollection.cs
- QilInvokeLateBound.cs
- ServiceRouteHandler.cs
- AdornerLayer.cs
- SimpleTypeResolver.cs
- TrackingServices.cs
- FixedSOMContainer.cs
- Schema.cs
- SqlFlattener.cs
- LinqDataSourceView.cs
- PrintPreviewControl.cs
- TemplateComponentConnector.cs
- OverflowException.cs
- MatrixAnimationUsingPath.cs
- DictionaryBase.cs
- XmlObjectSerializerContext.cs
- WebEventTraceProvider.cs
- SoapEnumAttribute.cs
- DataGridViewSortCompareEventArgs.cs
- UnsafeNativeMethods.cs
- mediaclock.cs
- DataGridCellsPanel.cs
- AutoCompleteStringCollection.cs
- FontFamily.cs
- EntityDataSourceDataSelectionPanel.cs
- ToolStripComboBox.cs
- KeyedCollection.cs
- VideoDrawing.cs
- RadioButtonList.cs
- ServiceHttpHandlerFactory.cs
- Int32AnimationUsingKeyFrames.cs
- PrintDialog.cs
- DoubleCollectionConverter.cs
- ToolStripItemGlyph.cs
- AdapterUtil.cs
- ArgumentOutOfRangeException.cs
- RequestQueue.cs
- InvalidDataException.cs
- UpdatePanelTriggerCollection.cs
- MenuItemAutomationPeer.cs
- SkewTransform.cs
- DispatcherObject.cs
- Connection.cs
- WorkflowView.cs
- EventProxy.cs
- EmptyReadOnlyDictionaryInternal.cs
- DateTimeConverter.cs
- UserNameSecurityToken.cs
- HitTestParameters.cs
- HttpContextServiceHost.cs
- SmtpMail.cs
- VariableExpressionConverter.cs
- Cursors.cs
- QilGenerator.cs
- EndCreateSecurityTokenRequest.cs
- AngleUtil.cs
- DbProviderSpecificTypePropertyAttribute.cs
- DynamicControl.cs
- ImageDrawing.cs
- SelectionListComponentEditor.cs
- ProgressBar.cs
- EventEntry.cs
- IISUnsafeMethods.cs
- CellLabel.cs
- NavigationWindowAutomationPeer.cs
- HttpContextBase.cs
- PathSegmentCollection.cs
- SystemMulticastIPAddressInformation.cs
- PrintPreviewGraphics.cs
- ComponentChangingEvent.cs
- DataGridViewColumnEventArgs.cs
- Geometry.cs
- AdCreatedEventArgs.cs
- QueryActivatableWorkflowsCommand.cs
- EventlogProvider.cs
- ClientRuntimeConfig.cs
- TranslateTransform.cs
- FragmentNavigationEventArgs.cs
- Form.cs
- XslCompiledTransform.cs
- M3DUtil.cs
- InterleavedZipPartStream.cs
- HotSpotCollection.cs
- PropertyGridEditorPart.cs
- AttributeEmitter.cs
- XmlSchemaAttributeGroupRef.cs
- BindingExpressionBase.cs
- HierarchicalDataTemplate.cs
- GridViewAutoFormat.cs
- NetworkInterface.cs
- ParserExtension.cs
- RadioButton.cs
- ScriptingAuthenticationServiceSection.cs
- PathFigureCollectionValueSerializer.cs
- FtpWebResponse.cs
- ScrollProperties.cs
- DesignerActionGlyph.cs
- SoapTypeAttribute.cs
- AutoGeneratedField.cs
- HttpProfileGroupBase.cs