Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PropertyEntry.cs
- DataRow.cs
- Asn1IntegerConverter.cs
- PackUriHelper.cs
- SecurityCredentialsManager.cs
- DetailsViewActionList.cs
- MultiTrigger.cs
- FamilyCollection.cs
- SoapCodeExporter.cs
- ExtendedProtectionPolicy.cs
- RelatedEnd.cs
- Cursors.cs
- ControlDesigner.cs
- BuildDependencySet.cs
- TreeBuilder.cs
- DataGrid.cs
- ASCIIEncoding.cs
- TypeDelegator.cs
- WindowsContainer.cs
- ExceptionValidationRule.cs
- IdentitySection.cs
- TextElementEnumerator.cs
- TabControlEvent.cs
- NativeCppClassAttribute.cs
- NavigationProperty.cs
- PackWebRequestFactory.cs
- PeerReferralPolicy.cs
- SecurityTokenSerializer.cs
- _NtlmClient.cs
- safelinkcollection.cs
- ToggleButtonAutomationPeer.cs
- WSFederationHttpBinding.cs
- DataGridViewCellFormattingEventArgs.cs
- CodeGotoStatement.cs
- GridLength.cs
- DataKeyArray.cs
- MessageDecoder.cs
- FamilyCollection.cs
- IsolatedStorageFilePermission.cs
- ResourceDescriptionAttribute.cs
- InheritanceRules.cs
- PagedDataSource.cs
- InternalBufferOverflowException.cs
- MultiSelectRootGridEntry.cs
- TextEmbeddedObject.cs
- ChangeConflicts.cs
- PreProcessor.cs
- XmlDataFileEditor.cs
- AuthorizationRule.cs
- HttpRequest.cs
- Oid.cs
- EntityClientCacheKey.cs
- RemoteCryptoSignHashRequest.cs
- WebServiceParameterData.cs
- Int16Converter.cs
- EventProxy.cs
- PrintEvent.cs
- RuntimeHandles.cs
- ArcSegment.cs
- AppDomainManager.cs
- Object.cs
- TableRow.cs
- DelegateTypeInfo.cs
- AlphabetConverter.cs
- AdapterDictionary.cs
- ApplicationSecurityInfo.cs
- SQLInt64Storage.cs
- PersonalizablePropertyEntry.cs
- SafeWaitHandle.cs
- Error.cs
- ConsoleKeyInfo.cs
- ShapingEngine.cs
- TreeNodeEventArgs.cs
- ColumnMapTranslator.cs
- SMSvcHost.cs
- VariableQuery.cs
- ClosableStream.cs
- DetailsViewUpdateEventArgs.cs
- SafeLibraryHandle.cs
- FileLevelControlBuilderAttribute.cs
- SqlClientFactory.cs
- ResourceManager.cs
- ClipboardData.cs
- EpmTargetTree.cs
- SiteMapNodeItemEventArgs.cs
- ContentOperations.cs
- QueryIntervalOp.cs
- TableRow.cs
- ConvertTextFrag.cs
- WSFederationHttpBindingCollectionElement.cs
- AppDomainManager.cs
- WaitHandle.cs
- StorageMappingFragment.cs
- LogRecordSequence.cs
- DispatcherFrame.cs
- XamlFilter.cs
- DateTimeSerializationSection.cs
- SetterBaseCollection.cs
- HwndKeyboardInputProvider.cs
- ReadOnlyCollection.cs