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
- LinkGrep.cs
- control.ime.cs
- TextContainerHelper.cs
- TriState.cs
- TableDetailsRow.cs
- RoleGroup.cs
- LineBreakRecord.cs
- DebugView.cs
- AppDomainProtocolHandler.cs
- WindowsListViewItemStartMenu.cs
- SQLByteStorage.cs
- BasePropertyDescriptor.cs
- Events.cs
- TraceLevelStore.cs
- IndentTextWriter.cs
- XmlSiteMapProvider.cs
- HtmlContainerControl.cs
- XPathAncestorIterator.cs
- NullRuntimeConfig.cs
- SecurityKeyEntropyMode.cs
- AxDesigner.cs
- SrgsOneOf.cs
- X509CertificateClaimSet.cs
- ElementHost.cs
- ResXBuildProvider.cs
- Condition.cs
- CookieParameter.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- ForwardPositionQuery.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- HttpDebugHandler.cs
- OutKeywords.cs
- SqlInfoMessageEvent.cs
- ViewManager.cs
- ContainerUtilities.cs
- Drawing.cs
- XomlCompilerResults.cs
- PeerTransportListenAddressConverter.cs
- MasterPage.cs
- EventLogPermissionEntry.cs
- LocatorBase.cs
- ParseHttpDate.cs
- AccessDataSource.cs
- CacheVirtualItemsEvent.cs
- WebPartConnectionsConfigureVerb.cs
- PersonalizationEntry.cs
- CustomAssemblyResolver.cs
- HttpListenerPrefixCollection.cs
- AppliesToBehaviorDecisionTable.cs
- LogicalExpr.cs
- EdmType.cs
- JapaneseCalendar.cs
- Random.cs
- ToolStripDesigner.cs
- VScrollProperties.cs
- GridViewAutomationPeer.cs
- Stopwatch.cs
- DetailsViewDeleteEventArgs.cs
- precedingquery.cs
- PerformanceCounterPermission.cs
- Internal.cs
- MetadataProperty.cs
- _NegotiateClient.cs
- _CommandStream.cs
- DynamicMethod.cs
- InvalidateEvent.cs
- CurrentChangingEventManager.cs
- DataGridCell.cs
- ItemAutomationPeer.cs
- MultiByteCodec.cs
- IPHostEntry.cs
- DataGridViewAutoSizeModeEventArgs.cs
- StyleSheetComponentEditor.cs
- XD.cs
- RowCache.cs
- RemoteWebConfigurationHost.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- DataServiceCollectionOfT.cs
- BlobPersonalizationState.cs
- RemoteWebConfigurationHostServer.cs
- TypeTypeConverter.cs
- VarRefManager.cs
- SoapException.cs
- MenuItemCollectionEditorDialog.cs
- RtfFormatStack.cs
- XmlTextReaderImplHelpers.cs
- OutputScope.cs
- MarkupCompilePass2.cs
- HMACMD5.cs
- WindowsAuthenticationModule.cs
- InvokeCompletedEventArgs.cs
- Viewport2DVisual3D.cs
- ReflectEventDescriptor.cs
- MeasureItemEvent.cs
- HotSpotCollection.cs
- XmlAnyElementAttribute.cs
- SharedPersonalizationStateInfo.cs
- UrlAuthorizationModule.cs
- LoginNameDesigner.cs
- TextDecorationCollection.cs