Skip to content

Commit ce9b92e

Browse files
Remove SecurityCriticalDataForSet
1 parent 7511ae4 commit ce9b92e

File tree

81 files changed

+948
-1074
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+948
-1074
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@ internal static Uri SiteOfOrigin
4949
[FriendAccessAllowed]
5050
get
5151
{
52-
Uri siteOfOrigin = SiteOfOriginForClickOnceApp;
53-
if (siteOfOrigin == null)
54-
{
55-
// Calling FixFileUri because BaseDirectory will be a c:\\ style path
56-
siteOfOrigin = BaseUriHelper.FixFileUri(new Uri(System.AppDomain.CurrentDomain.BaseDirectory));
57-
}
52+
// Calling FixFileUri because BaseDirectory will be a c:\\ style path
53+
Uri siteOfOrigin = BaseUriHelper.FixFileUri(new Uri(System.AppDomain.CurrentDomain.BaseDirectory));
5854
#if DEBUG
5955
if (_traceSwitch.Enabled)
6056
System.Diagnostics.Trace.TraceInformation(
@@ -66,40 +62,16 @@ internal static Uri SiteOfOrigin
6662
return siteOfOrigin;
6763
}
6864
}
69-
70-
// we separated this from the rest of the code because this code is used for media permission
71-
// tests in partial trust but we want to do this without hitting the code path for regular exe's
72-
// as in the code above. This will get hit for click once apps, xbaps, xaml and xps
73-
internal static Uri SiteOfOriginForClickOnceApp
74-
{
75-
get
76-
{
77-
// The ClickOnce API, ApplicationDeployment.IsNetworkDeployed, determines whether the app is network-deployed
78-
// by getting the ApplicationDeployment.CurrentDeployment property and catch the exception it can throw.
79-
// The exception is a first chance exception and caught, but it often confuses developers,
80-
// and can also have a perf impact. So we change to cache the value of SiteofOrigin in Dev10 to avoid the
81-
// exception being thrown too many times.
82-
// An alternative is to cache the value of ApplicationDeployment.IsNetworkDeployed.
83-
if (_siteOfOriginForClickOnceApp == null)
84-
{
85-
_siteOfOriginForClickOnceApp = new SecurityCriticalDataForSet<Uri>(null);
86-
}
87-
88-
Invariant.Assert(_siteOfOriginForClickOnceApp != null);
89-
90-
return _siteOfOriginForClickOnceApp.Value.Value;
91-
}
92-
}
9365

9466
internal static Uri BrowserSource
9567
{
9668
get
9769
{
98-
return _browserSource.Value;
70+
return _browserSource;
9971
}
10072
set
10173
{
102-
_browserSource.Value = value;
74+
_browserSource = value;
10375
}
10476
}
10577

@@ -246,8 +218,7 @@ protected override PackagePart GetPartCore(Uri uri)
246218

247219
#region Private Members
248220

249-
private static SecurityCriticalDataForSet<Uri> _browserSource;
250-
private static SecurityCriticalDataForSet<Uri>? _siteOfOriginForClickOnceApp;
221+
private static Uri _browserSource;
251222

252223
#endregion Private Members
253224

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/UshortList2.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,33 +277,33 @@ internal unsafe class UnsafeUshortArray : UshortBuffer
277277
{
278278
private ushort* _array;
279279

280-
private SecurityCriticalDataForSet<int> _arrayLength;
280+
private int _arrayLength;
281281

282282

283283
internal UnsafeUshortArray(CheckedUShortPointer array, int arrayLength)
284284
{
285285
_array = array.Probe(0, arrayLength);
286-
_arrayLength.Value = arrayLength;
286+
_arrayLength = arrayLength;
287287
}
288288

289289

290290
public override ushort this[int index]
291291
{
292292
get
293293
{
294-
Invariant.Assert(index >= 0 && index < _arrayLength.Value);
294+
Invariant.Assert(index >= 0 && index < _arrayLength);
295295
return _array[index];
296296
}
297297
set
298298
{
299-
Invariant.Assert(index >= 0 && index < _arrayLength.Value);
299+
Invariant.Assert(index >= 0 && index < _arrayLength);
300300
_array[index] = value;
301301
}
302302
}
303303

304304
public override int Length
305305
{
306-
get { return _arrayLength.Value; }
306+
get { return _arrayLength; }
307307
}
308308
}
309309
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextBreakpoint.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ namespace MS.Internal.TextFormatting
3838
internal sealed class FullTextBreakpoint : TextBreakpoint
3939
{
4040
private TextMetrics _metrics; // full text metrics
41-
private SecurityCriticalDataForSet<IntPtr> _ploline; // native object representing this break
42-
private SecurityCriticalDataForSet<IntPtr> _penaltyResource; // unsafe handle to the internal factors used to determines penalty of the break. By default, the lifetime of this resource is managed by _ploline.
41+
private IntPtr _ploline; // native object representing this break
42+
private IntPtr _penaltyResource; // unsafe handle to the internal factors used to determines penalty of the break. By default, the lifetime of this resource is managed by _ploline.
4343
private bool _isDisposed; // flag indicates whether this object is disposed
4444
private bool _isLineTruncated; // flag indicates whether the line produced at this breakpoint is truncated.
4545

@@ -86,7 +86,7 @@ out int bestFitIndex
8686

8787
IntPtr previousBreakRecord = IntPtr.Zero;
8888
if (settings.PreviousLineBreak != null)
89-
previousBreakRecord = settings.PreviousLineBreak.BreakRecord.Value;
89+
previousBreakRecord = settings.PreviousLineBreak.BreakRecord;
9090

9191
// need not consider marker as tab since marker does not affect line metrics and it wasnt drawn.
9292
fullText.SetTabs(context);
@@ -96,7 +96,7 @@ out int bestFitIndex
9696
LsErr lserr = context.CreateBreaks(
9797
fullText.GetBreakpointInternalCp(firstCharIndex),
9898
previousBreakRecord,
99-
paragraphCache.Ploparabreak.Value, // para breaking session
99+
paragraphCache.Ploparabreak, // para breaking session
100100
penaltyRestriction,
101101
ref lsbreaks,
102102
out bestFitIndex
@@ -180,10 +180,10 @@ int breakIndex
180180
&lsbreaks.plslinfoArray[breakIndex]
181181
);
182182

183-
_ploline = new SecurityCriticalDataForSet<IntPtr>(lsbreaks.pplolineArray[breakIndex]);
183+
_ploline = lsbreaks.pplolineArray[breakIndex];
184184

185185
// keep the line penalty handle
186-
_penaltyResource = new SecurityCriticalDataForSet<IntPtr>(lsbreaks.plinepenaltyArray[breakIndex]);
186+
_penaltyResource = lsbreaks.plinepenaltyArray[breakIndex];
187187

188188
if (lsbreaks.plslinfoArray[breakIndex].fForcedBreak != 0)
189189
_isLineTruncated = true;
@@ -214,11 +214,11 @@ private FullTextBreakpoint()
214214
/// </summary>
215215
protected override void Dispose(bool disposing)
216216
{
217-
if(_ploline.Value != IntPtr.Zero)
217+
if(_ploline != IntPtr.Zero)
218218
{
219-
UnsafeNativeMethods.LoDisposeLine(_ploline.Value, !disposing);
220-
_ploline.Value = IntPtr.Zero;
221-
_penaltyResource.Value = IntPtr.Zero;
219+
UnsafeNativeMethods.LoDisposeLine(_ploline, !disposing);
220+
_ploline = IntPtr.Zero;
221+
_penaltyResource = IntPtr.Zero;
222222
_isDisposed = true;
223223
GC.KeepAlive(this);
224224
}
@@ -238,7 +238,7 @@ public override TextLineBreak GetTextLineBreak()
238238
{
239239
throw new ObjectDisposedException(SR.Get(SRID.TextBreakpointHasBeenDisposed));
240240
}
241-
return _metrics.GetTextLineBreak(_ploline.Value);
241+
return _metrics.GetTextLineBreak(_ploline);
242242
}
243243

244244

@@ -250,14 +250,14 @@ public override TextLineBreak GetTextLineBreak()
250250
/// We would make a correspondent call to notify our unmanaged wrapper to release them from duty of managing this
251251
/// resource.
252252
/// </remarks>
253-
internal override SecurityCriticalDataForSet<IntPtr> GetTextPenaltyResource()
253+
internal override IntPtr GetTextPenaltyResource()
254254
{
255255
if (_isDisposed)
256256
{
257257
throw new ObjectDisposedException(SR.Get(SRID.TextBreakpointHasBeenDisposed));
258258
}
259259

260-
LsErr lserr = UnsafeNativeMethods.LoRelievePenaltyResource(_ploline.Value);
260+
LsErr lserr = UnsafeNativeMethods.LoRelievePenaltyResource(_ploline);
261261
if (lserr != LsErr.None)
262262
{
263263
TextFormatterContext.ThrowExceptionFromLsError(SR.Get(SRID.RelievePenaltyResourceFailure, lserr), lserr);

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/FullTextLine.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ internal class FullTextLine : TextLine
5050
private int _depthQueryMax; // maximum depth of reversals used in querying
5151
private int _paragraphWidth; // paragraph width
5252
private int _textMinWidthAtTrailing; // smallest text width excluding trailing whitespaces
53-
private SecurityCriticalDataForSet<IntPtr> _ploline; // actual LS line
54-
private SecurityCriticalDataForSet<IntPtr> _ploc; // actual LS context
53+
private IntPtr _ploline; // actual LS line
54+
private IntPtr _ploc; // actual LS context
5555
private Overhang _overhang; // overhang metrics
5656
private StatusFlags _statusFlags; // status flags of the line
5757

@@ -157,11 +157,11 @@ public override void Dispose()
157157
/// </summary>
158158
private void DisposeInternal(bool finalizing)
159159
{
160-
if (_ploline.Value != System.IntPtr.Zero)
160+
if (_ploline != System.IntPtr.Zero)
161161
{
162-
UnsafeNativeMethods.LoDisposeLine(_ploline.Value, finalizing);
162+
UnsafeNativeMethods.LoDisposeLine(_ploline, finalizing);
163163

164-
_ploline.Value = System.IntPtr.Zero;
164+
_ploline = System.IntPtr.Zero;
165165
GC.KeepAlive(this);
166166
}
167167
}
@@ -179,7 +179,7 @@ private FullTextLine(TextFormattingMode textFormattingMode, bool justify, double
179179
}
180180
_metrics = new TextMetrics();
181181
_metrics._pixelsPerDip = pixelsPerDip;
182-
_ploline = new SecurityCriticalDataForSet<IntPtr>(IntPtr.Zero);
182+
_ploline = IntPtr.Zero;
183183
}
184184

185185

@@ -301,7 +301,7 @@ out lineWidths
301301
}
302302
}
303303

304-
_ploline.Value = ploline;
304+
_ploline = ploline;
305305

306306
// get the exception in context before it is released
307307
Exception callbackException = context.CallbackException;
@@ -596,7 +596,7 @@ MatrixTransform antiInversion
596596
{
597597
Rect boundingBox = Rect.Empty;
598598

599-
if (_ploline.Value != System.IntPtr.Zero)
599+
if (_ploline != System.IntPtr.Zero)
600600
{
601601
TextFormatterContext context;
602602
LsErr lserr = LsErr.None;
@@ -607,7 +607,7 @@ MatrixTransform antiInversion
607607
{
608608
context = _metrics._formatter.AcquireContext(
609609
drawingState,
610-
_ploc.Value
610+
_ploc
611611
);
612612

613613
// set the collector and send the line to LS to draw
@@ -618,7 +618,7 @@ MatrixTransform antiInversion
618618
LSPOINT lsRefOrigin = new LSPOINT(0, _metrics._baselineOffset);
619619

620620
lserr = UnsafeNativeMethods.LoDisplayLine(
621-
_ploline.Value,
621+
_ploline,
622622
ref lsRefOrigin,
623623
1, // 0 - opaque, 1 - transparent
624624
ref rect
@@ -868,7 +868,7 @@ private CharacterHit CharacterHitFromDistance(int hitTestDistance)
868868
// assuming the first cp of the line
869869
CharacterHit characterHit = new CharacterHit(_cpFirst, 0);
870870

871-
if(_ploline.Value == IntPtr.Zero)
871+
if(_ploline == IntPtr.Zero)
872872
{
873873
// Returning the first cp for the empty line
874874
return characterHit;
@@ -1003,7 +1003,7 @@ private int DistanceFromCharacterHit(CharacterHit characterHit)
10031003
{
10041004
int hitTestDistance = 0;
10051005

1006-
if (_ploline.Value == IntPtr.Zero)
1006+
if (_ploline == IntPtr.Zero)
10071007
{
10081008
// Returning start of the line for empty line
10091009
return hitTestDistance;
@@ -1151,7 +1151,7 @@ CharacterHit characterHit
11511151

11521152
TextFormatterImp.VerifyCaretCharacterHit(characterHit, _cpFirst, _metrics._cchLength);
11531153

1154-
if (_ploline.Value == System.IntPtr.Zero)
1154+
if (_ploline == System.IntPtr.Zero)
11551155
{
11561156
return characterHit;
11571157
}
@@ -1244,7 +1244,7 @@ CaretDirection direction
12441244

12451245
TextFormatterImp.VerifyCaretCharacterHit(characterHit, _cpFirst, _metrics._cchLength);
12461246

1247-
if (_ploline.Value == IntPtr.Zero)
1247+
if (_ploline == IntPtr.Zero)
12481248
{
12491249
return characterHit;
12501250
}
@@ -1524,7 +1524,7 @@ int textLength
15241524
textLength = (_cpFirst + _metrics._cchLength - firstTextSourceCharacterIndex);
15251525
}
15261526

1527-
if (_ploline.Value == IntPtr.Zero)
1527+
if (_ploline == IntPtr.Zero)
15281528
{
15291529
return CreateDegenerateBounds();
15301530
}
@@ -2136,11 +2136,11 @@ public override IEnumerable<IndexedGlyphRun> GetIndexedGlyphRuns()
21362136

21372137
IEnumerable<IndexedGlyphRun> result = null;
21382138

2139-
if (_ploline.Value != System.IntPtr.Zero)
2139+
if (_ploline != System.IntPtr.Zero)
21402140
{
21412141
TextFormatterContext context = _metrics._formatter.AcquireContext(
21422142
new DrawingState(null, new Point(0, 0), null, this),
2143-
_ploc.Value
2143+
_ploc
21442144
);
21452145

21462146
//
@@ -2150,7 +2150,7 @@ public override IEnumerable<IndexedGlyphRun> GetIndexedGlyphRuns()
21502150

21512151
LSPOINT point = new LSPOINT(0, 0);
21522152
lserr = UnsafeNativeMethods.LoEnumLine(
2153-
_ploline.Value, // line
2153+
_ploline, // line
21542154
false, // reverse enumeration
21552155
false, // geometry needed
21562156
ref point // starting point
@@ -2459,7 +2459,7 @@ private void QueryLinePointPcp(
24592459
out LsTextCell lsTextCell
24602460
)
24612461
{
2462-
Debug.Assert(_ploline.Value != IntPtr.Zero);
2462+
Debug.Assert(_ploline != IntPtr.Zero);
24632463

24642464
LsErr lserr = LsErr.None;
24652465
lsTextCell = new LsTextCell();
@@ -2469,7 +2469,7 @@ out LsTextCell lsTextCell
24692469
{
24702470
LSPOINT pt = new LSPOINT((int)ptQuery.X, (int)ptQuery.Y);
24712471
lserr = UnsafeNativeMethods.LoQueryLinePointPcp(
2472-
_ploline.Value,
2472+
_ploline,
24732473
ref pt,
24742474
subLineInfo.Length,
24752475
(System.IntPtr)plsqsubl,
@@ -2512,7 +2512,7 @@ private void QueryLineCpPpoint(
25122512
out LsTextCell lsTextCell
25132513
)
25142514
{
2515-
Debug.Assert(_ploline.Value != IntPtr.Zero);
2515+
Debug.Assert(_ploline != IntPtr.Zero);
25162516

25172517
LsErr lserr = LsErr.None;
25182518

@@ -2526,7 +2526,7 @@ out LsTextCell lsTextCell
25262526
fixed(LsQSubInfo* plsqsubl = subLineInfo)
25272527
{
25282528
lserr = UnsafeNativeMethods.LoQueryLineCpPpoint(
2529-
_ploline.Value,
2529+
_ploline,
25302530
lscpValidQuery,
25312531
subLineInfo.Length,
25322532
(System.IntPtr)plsqsubl,

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ IntPtr ploc
569569
if(context.Owner == null)
570570
break;
571571
}
572-
else if (ploc == context.Ploc.Value)
572+
else if (ploc == context.Ploc)
573573
{
574574
// LS requires that we use the exact same context for line
575575
// destruction or hittesting (part of the reason is that LS

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextMetrics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,10 @@ internal TextLineBreak GetTextLineBreak(IntPtr ploline)
319319
{
320320
return new TextLineBreak(
321321
_lastRun.TextModifierScope,
322-
new SecurityCriticalDataForSet<IntPtr>(pbreakrec)
322+
pbreakrec
323323
);
324324
}
325-
return (pbreakrec != IntPtr.Zero) ? new TextLineBreak(null, new SecurityCriticalDataForSet<IntPtr>(pbreakrec)) : null;
325+
return (pbreakrec != IntPtr.Zero) ? new TextLineBreak(null, pbreakrec) : null;
326326
}
327327

328328

0 commit comments

Comments
 (0)