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
- PermissionSetTriple.cs
- ToolboxItemCollection.cs
- QuadraticBezierSegment.cs
- InternalMappingException.cs
- BrowserTree.cs
- ZipIOBlockManager.cs
- Attributes.cs
- SkipQueryOptionExpression.cs
- DiagnosticsConfiguration.cs
- FixedSchema.cs
- TraceData.cs
- WorkflowTerminatedException.cs
- ReversePositionQuery.cs
- PointConverter.cs
- PageContent.cs
- Error.cs
- StylusEditingBehavior.cs
- LineBreakRecord.cs
- GridView.cs
- UnlockInstanceAsyncResult.cs
- DataTransferEventArgs.cs
- WmpBitmapEncoder.cs
- FormViewUpdateEventArgs.cs
- DockProviderWrapper.cs
- StyleModeStack.cs
- XsdBuildProvider.cs
- OracleNumber.cs
- ProgressBar.cs
- TdsValueSetter.cs
- DataContractSerializerMessageContractImporter.cs
- TreeNode.cs
- NavigationEventArgs.cs
- DecoderBestFitFallback.cs
- CheckBoxAutomationPeer.cs
- PriorityQueue.cs
- FormattedTextSymbols.cs
- XmlNullResolver.cs
- ListViewPagedDataSource.cs
- SqlBuilder.cs
- BooleanFunctions.cs
- SequenceRange.cs
- FixUpCollection.cs
- BitmapDownload.cs
- SkinIDTypeConverter.cs
- CompareValidator.cs
- VisualStateGroup.cs
- DocumentReference.cs
- input.cs
- Roles.cs
- cookiecollection.cs
- RelationalExpressions.cs
- StylusDownEventArgs.cs
- JsonFormatGeneratorStatics.cs
- WinFormsComponentEditor.cs
- TypefaceMetricsCache.cs
- ThumbAutomationPeer.cs
- StaticFileHandler.cs
- DataGridTextColumn.cs
- XmlQueryTypeFactory.cs
- LocalizationComments.cs
- Converter.cs
- AQNBuilder.cs
- DiscreteKeyFrames.cs
- Misc.cs
- CodeEventReferenceExpression.cs
- BoundsDrawingContextWalker.cs
- HandlerBase.cs
- IpcPort.cs
- MulticastOption.cs
- _ListenerResponseStream.cs
- ConnectionManagementElementCollection.cs
- GenericIdentity.cs
- Sentence.cs
- XmlUnspecifiedAttribute.cs
- BamlVersionHeader.cs
- Utils.cs
- ItemDragEvent.cs
- HasRunnableWorkflowEvent.cs
- ModuleBuilderData.cs
- CompiledRegexRunner.cs
- CodeAttachEventStatement.cs
- ParameterCollection.cs
- TemplateGroupCollection.cs
- WebPartAuthorizationEventArgs.cs
- GacUtil.cs
- EditorAttribute.cs
- ContentPlaceHolder.cs
- InternalBase.cs
- UnsafeNativeMethods.cs
- categoryentry.cs
- NewArrayExpression.cs
- FormViewUpdateEventArgs.cs
- SynchronizedInputPattern.cs
- HtmlLink.cs
- DebugView.cs
- WebPartPersonalization.cs
- Vector3DAnimation.cs
- DockAndAnchorLayout.cs
- UriSection.cs
- IisTraceListener.cs