Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / MS / Internal / CheckedPointers.cs / 1305600 / CheckedPointers.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: Checked pointers for various types // // History: // 05/09/2005: Garyyang Created the file // //--------------------------------------------------------------------------- using System; using System.Security; using MS.Internal.Shaping; using MS.Internal.FontCache; // // The file contains wrapper structs for various pointer types. // This is to allow us passing these pointers safely in layout code and provides // some bound checking. Only construction and probing into these pointers are security critical. // namespace MS.Internal { ////// Checked pointer for (Char*) /// internal struct CheckedCharPointer { ////// Critical - The method takes unsafe pointer /// [SecurityCritical] internal unsafe CheckedCharPointer(char * pointer, int length) { _checkedPointer = new CheckedPointer(pointer, length * sizeof(char)); } ////// Critical - The method returns unsafe pointer /// [SecurityCritical] internal unsafe char * Probe(int offset, int length) { return (char*) _checkedPointer.Probe(offset * sizeof(char), length * sizeof(char)); } private CheckedPointer _checkedPointer; } ////// Checked pointer for (int*) /// internal struct CheckedIntPointer { ////// Critical - The method takes unsafe pointer /// [SecurityCritical] internal unsafe CheckedIntPointer(int * pointer, int length) { _checkedPointer = new CheckedPointer(pointer, length * sizeof(int)); } ////// Critical - The method returns unsafe pointer /// [SecurityCritical] internal unsafe int * Probe(int offset, int length) { return (int *) _checkedPointer.Probe(offset * sizeof(int), length * sizeof(int)); } private CheckedPointer _checkedPointer; } ////// Checked pointer for (ushort*) /// internal struct CheckedUShortPointer { ////// Critical - The method takes unsafe pointer /// [SecurityCritical] internal unsafe CheckedUShortPointer(ushort * pointer, int length) { _checkedPointer = new CheckedPointer(pointer, length * sizeof(ushort)); } ////// Critical - The method returns unsafe pointer /// [SecurityCritical] internal unsafe ushort * Probe(int offset, int length) { return (ushort *) _checkedPointer.Probe(offset * sizeof(ushort), length * sizeof(ushort)); } private CheckedPointer _checkedPointer; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: Checked pointers for various types // // History: // 05/09/2005: Garyyang Created the file // //--------------------------------------------------------------------------- using System; using System.Security; using MS.Internal.Shaping; using MS.Internal.FontCache; // // The file contains wrapper structs for various pointer types. // This is to allow us passing these pointers safely in layout code and provides // some bound checking. Only construction and probing into these pointers are security critical. // namespace MS.Internal { ////// Checked pointer for (Char*) /// internal struct CheckedCharPointer { ////// Critical - The method takes unsafe pointer /// [SecurityCritical] internal unsafe CheckedCharPointer(char * pointer, int length) { _checkedPointer = new CheckedPointer(pointer, length * sizeof(char)); } ////// Critical - The method returns unsafe pointer /// [SecurityCritical] internal unsafe char * Probe(int offset, int length) { return (char*) _checkedPointer.Probe(offset * sizeof(char), length * sizeof(char)); } private CheckedPointer _checkedPointer; } ////// Checked pointer for (int*) /// internal struct CheckedIntPointer { ////// Critical - The method takes unsafe pointer /// [SecurityCritical] internal unsafe CheckedIntPointer(int * pointer, int length) { _checkedPointer = new CheckedPointer(pointer, length * sizeof(int)); } ////// Critical - The method returns unsafe pointer /// [SecurityCritical] internal unsafe int * Probe(int offset, int length) { return (int *) _checkedPointer.Probe(offset * sizeof(int), length * sizeof(int)); } private CheckedPointer _checkedPointer; } ////// Checked pointer for (ushort*) /// internal struct CheckedUShortPointer { ////// Critical - The method takes unsafe pointer /// [SecurityCritical] internal unsafe CheckedUShortPointer(ushort * pointer, int length) { _checkedPointer = new CheckedPointer(pointer, length * sizeof(ushort)); } ////// Critical - The method returns unsafe pointer /// [SecurityCritical] internal unsafe ushort * Probe(int offset, int length) { return (ushort *) _checkedPointer.Probe(offset * sizeof(ushort), length * sizeof(ushort)); } private CheckedPointer _checkedPointer; } } // 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
- UnsafeNativeMethods.cs
- Trace.cs
- RegexRunner.cs
- FrameSecurityDescriptor.cs
- TableLayoutCellPaintEventArgs.cs
- Error.cs
- DefaultEventAttribute.cs
- ThreadExceptionDialog.cs
- XmlSchemaSet.cs
- SmtpFailedRecipientsException.cs
- StubHelpers.cs
- PixelFormats.cs
- IdentityNotMappedException.cs
- WhitespaceReader.cs
- WaitHandle.cs
- ObjectDataSourceDisposingEventArgs.cs
- TextViewSelectionProcessor.cs
- Axis.cs
- DispatcherObject.cs
- StackOverflowException.cs
- CellCreator.cs
- TrustLevelCollection.cs
- Internal.cs
- SecurityProtocolCorrelationState.cs
- DesignerDeviceConfig.cs
- DrawingBrush.cs
- CodeMemberMethod.cs
- SemanticKeyElement.cs
- WithStatement.cs
- TreeViewItemAutomationPeer.cs
- PageBuildProvider.cs
- ValidatingPropertiesEventArgs.cs
- PropertyTabChangedEvent.cs
- ByteRangeDownloader.cs
- DebuggerService.cs
- ADConnectionHelper.cs
- EventLogWatcher.cs
- TableItemPattern.cs
- DataGridViewColumnConverter.cs
- DoubleUtil.cs
- QilGeneratorEnv.cs
- StylusPointPropertyId.cs
- EdmTypeAttribute.cs
- SqlUdtInfo.cs
- StorageEntityTypeMapping.cs
- AppearanceEditorPart.cs
- UriWriter.cs
- EventlogProvider.cs
- SoapInteropTypes.cs
- ScrollItemPatternIdentifiers.cs
- ExtensionWindowHeader.cs
- Events.cs
- DispatcherSynchronizationContext.cs
- BidPrivateBase.cs
- Accessible.cs
- AxImporter.cs
- OrElse.cs
- SuppressMergeCheckAttribute.cs
- SqlClientPermission.cs
- ILGen.cs
- RelationshipFixer.cs
- JavascriptXmlWriterWrapper.cs
- ClrPerspective.cs
- DateTimeOffset.cs
- ColumnMapProcessor.cs
- WorkflowQueuingService.cs
- SizeAnimationBase.cs
- InputDevice.cs
- RuntimeConfigurationRecord.cs
- QueryStringConverter.cs
- DesignerAttribute.cs
- XsltConvert.cs
- ConfigXmlWhitespace.cs
- ApplicationBuildProvider.cs
- ImageSourceConverter.cs
- PartManifestEntry.cs
- AttributeQuery.cs
- IgnorePropertiesAttribute.cs
- IIS7WorkerRequest.cs
- DefaultTraceListener.cs
- StreamGeometryContext.cs
- NumberSubstitution.cs
- DataMisalignedException.cs
- BitmapMetadataEnumerator.cs
- AttributeCollection.cs
- ConnectionPoolManager.cs
- DataList.cs
- ErrorWrapper.cs
- PasswordRecoveryAutoFormat.cs
- AddInServer.cs
- ImplicitInputBrush.cs
- ScriptManager.cs
- JoinSymbol.cs
- MsmqHostedTransportConfiguration.cs
- StretchValidation.cs
- DropShadowEffect.cs
- safemediahandle.cs
- ListViewUpdateEventArgs.cs
- MachineKeySection.cs
- BuildManagerHost.cs