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
- MultiPageTextView.cs
- RadioButtonStandardAdapter.cs
- AspNetPartialTrustHelpers.cs
- XmlToDatasetMap.cs
- DefaultBinder.cs
- TraceSection.cs
- HitTestFilterBehavior.cs
- metadatamappinghashervisitor.hashsourcebuilder.cs
- DataTablePropertyDescriptor.cs
- DescendantOverDescendantQuery.cs
- BlobPersonalizationState.cs
- AbandonedMutexException.cs
- ITextView.cs
- StylusButton.cs
- WaitForChangedResult.cs
- Block.cs
- SoapIncludeAttribute.cs
- OutOfProcStateClientManager.cs
- WebPartMovingEventArgs.cs
- assemblycache.cs
- Types.cs
- UnauthorizedWebPart.cs
- MessageDescription.cs
- ObjectManager.cs
- ColumnResizeUndoUnit.cs
- IndexObject.cs
- XmlReturnReader.cs
- XmlCodeExporter.cs
- GlyphsSerializer.cs
- RegularExpressionValidator.cs
- XmlQueryRuntime.cs
- WebPartsPersonalizationAuthorization.cs
- FormatConvertedBitmap.cs
- SafeFindHandle.cs
- RadioButtonPopupAdapter.cs
- CodeConditionStatement.cs
- PageThemeCodeDomTreeGenerator.cs
- ToolboxBitmapAttribute.cs
- Variable.cs
- xamlnodes.cs
- Roles.cs
- HostingEnvironment.cs
- MsmqActivation.cs
- GCHandleCookieTable.cs
- Transform.cs
- GeneralTransform.cs
- AdRotator.cs
- EdmType.cs
- ContextMenuAutomationPeer.cs
- ConfigurationValues.cs
- RequestSecurityTokenResponseCollection.cs
- ExpressionTextBoxAutomationPeer.cs
- WebConvert.cs
- EdmComplexPropertyAttribute.cs
- XmlLanguageConverter.cs
- PriorityQueue.cs
- TimerElapsedEvenArgs.cs
- AnimationLayer.cs
- KeyboardEventArgs.cs
- ListItemCollection.cs
- SchemaObjectWriter.cs
- PropertyEmitter.cs
- GridViewColumnHeaderAutomationPeer.cs
- XslTransformFileEditor.cs
- OrderedDictionaryStateHelper.cs
- MachineKeyValidationConverter.cs
- EnumConverter.cs
- CornerRadiusConverter.cs
- WindowsSysHeader.cs
- NamedPipeTransportSecurityElement.cs
- TypeBuilder.cs
- QilFactory.cs
- EnglishPluralizationService.cs
- ResXResourceReader.cs
- Comparer.cs
- NamespaceDecl.cs
- XmlReflectionImporter.cs
- EventLogHandle.cs
- DropAnimation.xaml.cs
- SchemaImporter.cs
- AnimationClockResource.cs
- GatewayIPAddressInformationCollection.cs
- HtmlFormWrapper.cs
- FileDialogCustomPlacesCollection.cs
- AesManaged.cs
- PrinterUnitConvert.cs
- TreeNodeConverter.cs
- PageAsyncTask.cs
- TableDetailsRow.cs
- WebPartTransformer.cs
- FixedNode.cs
- DefaultObjectMappingItemCollection.cs
- Automation.cs
- PriorityRange.cs
- SymLanguageType.cs
- PropertySegmentSerializer.cs
- SynchronizationValidator.cs
- RuleSettings.cs
- QilTernary.cs
- WebConfigurationHost.cs