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
- QueryOutputWriter.cs
- DependencyPropertyDescriptor.cs
- MessageVersionConverter.cs
- SymbolTable.cs
- CapabilitiesAssignment.cs
- SamlSubject.cs
- ProfessionalColorTable.cs
- DesignerAdRotatorAdapter.cs
- EventListener.cs
- FloaterBaseParaClient.cs
- PrinterSettings.cs
- InternalConfigConfigurationFactory.cs
- InstalledVoice.cs
- Label.cs
- AmbientLight.cs
- WebScriptServiceHostFactory.cs
- PhysicalAddress.cs
- AsyncOperationManager.cs
- ObjectListDesigner.cs
- AttachedAnnotationChangedEventArgs.cs
- EditorZone.cs
- ACL.cs
- RecognizerBase.cs
- DataGridTemplateColumn.cs
- HashAlgorithm.cs
- Predicate.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- propertyentry.cs
- AccessViolationException.cs
- XamlReaderHelper.cs
- TableAdapterManagerMethodGenerator.cs
- SqlTypeSystemProvider.cs
- DocumentSchemaValidator.cs
- WebPartDescriptionCollection.cs
- StandardRuntimeEnumValidatorAttribute.cs
- VoiceObjectToken.cs
- TagPrefixAttribute.cs
- CommonDialog.cs
- LassoSelectionBehavior.cs
- Nullable.cs
- SpotLight.cs
- SpeechEvent.cs
- ProcessInputEventArgs.cs
- TextMetrics.cs
- ActivationArguments.cs
- ToolStripItemGlyph.cs
- PropertyPathWorker.cs
- PackagePartCollection.cs
- TextEditorCharacters.cs
- FillRuleValidation.cs
- PersianCalendar.cs
- PageWrapper.cs
- ValidationError.cs
- Symbol.cs
- StringConverter.cs
- DocumentGridContextMenu.cs
- NegotiateStream.cs
- DataConnectionHelper.cs
- ByteStorage.cs
- RequestQueryParser.cs
- SqlCacheDependency.cs
- Propagator.Evaluator.cs
- SafeNativeMethods.cs
- KeyTimeConverter.cs
- ManagementOperationWatcher.cs
- UIElement.cs
- ProfileSection.cs
- TabPage.cs
- Triangle.cs
- DesignTimeXamlWriter.cs
- CacheRequest.cs
- ProfileSettingsCollection.cs
- InvalidCommandTreeException.cs
- TabControlEvent.cs
- SyndicationItemFormatter.cs
- DataGridViewCellStyleConverter.cs
- OleDbTransaction.cs
- NativeMethods.cs
- WarningException.cs
- IdentifierService.cs
- ProfileProvider.cs
- PngBitmapDecoder.cs
- GradientStop.cs
- InvalidOperationException.cs
- AssemblyName.cs
- shaperfactoryquerycachekey.cs
- WebPartExportVerb.cs
- EventDescriptor.cs
- SqlPersonalizationProvider.cs
- Animatable.cs
- TextLineBreak.cs
- ParentControlDesigner.cs
- DragDeltaEventArgs.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- ExeContext.cs
- WebControlAdapter.cs
- SymbolDocumentInfo.cs
- UserControl.cs
- WaitingCursor.cs
- AspCompat.cs