Project: Convert to .NET 5.0

This commit is contained in:
Gus
2021-02-08 17:50:27 +01:00
parent 8630a89553
commit 0ea33ff35c
10 changed files with 136 additions and 1068 deletions
+87 -75
View File
@@ -5,6 +5,7 @@ using System;
namespace SevenZip.Compression.LZMA namespace SevenZip.Compression.LZMA
{ {
using RangeCoder; using RangeCoder;
using System.Threading;
public class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream public class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream
{ {
@@ -228,7 +229,7 @@ namespace SevenZip.Compression.LZMA
} }
public void Code(System.IO.Stream inStream, System.IO.Stream outStream, public void Code(System.IO.Stream inStream, System.IO.Stream outStream,
Int64 inSize, Int64 outSize, ICodeProgress progress) Int64 inSize, Int64 outSize, ICodeProgress progress, CancellationToken? token = null)
{ {
Init(inStream, outStream); Init(inStream, outStream);
@@ -247,100 +248,111 @@ namespace SevenZip.Compression.LZMA
m_OutWindow.PutByte(b); m_OutWindow.PutByte(b);
nowPos64++; nowPos64++;
} }
while (nowPos64 < outSize64)
try
{ {
// UInt64 next = Math.Min(nowPos64 + (1 << 18), outSize64); while (nowPos64 < outSize64)
// while(nowPos64 < next)
{ {
uint posState = (uint)nowPos64 & m_PosStateMask; token?.ThrowIfCancellationRequested();
if (m_IsMatchDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0)
// UInt64 next = Math.Min(nowPos64 + (1 << 18), outSize64);
// while(nowPos64 < next)
{ {
byte b; uint posState = (uint)nowPos64 & m_PosStateMask;
byte prevByte = m_OutWindow.GetByte(0); if (m_IsMatchDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0)
if (!state.IsCharState())
b = m_LiteralDecoder.DecodeWithMatchByte(m_RangeDecoder,
(uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0));
else
b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, (uint)nowPos64, prevByte);
m_OutWindow.PutByte(b);
state.UpdateChar();
nowPos64++;
}
else
{
uint len;
if (m_IsRepDecoders[state.Index].Decode(m_RangeDecoder) == 1)
{ {
if (m_IsRepG0Decoders[state.Index].Decode(m_RangeDecoder) == 0) byte b;
{ byte prevByte = m_OutWindow.GetByte(0);
if (m_IsRep0LongDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0) if (!state.IsCharState())
{ b = m_LiteralDecoder.DecodeWithMatchByte(m_RangeDecoder,
state.UpdateShortRep(); (uint)nowPos64, prevByte, m_OutWindow.GetByte(rep0));
m_OutWindow.PutByte(m_OutWindow.GetByte(rep0));
nowPos64++;
continue;
}
}
else else
b = m_LiteralDecoder.DecodeNormal(m_RangeDecoder, (uint)nowPos64, prevByte);
m_OutWindow.PutByte(b);
state.UpdateChar();
nowPos64++;
}
else
{
uint len;
if (m_IsRepDecoders[state.Index].Decode(m_RangeDecoder) == 1)
{ {
UInt32 distance; if (m_IsRepG0Decoders[state.Index].Decode(m_RangeDecoder) == 0)
if (m_IsRepG1Decoders[state.Index].Decode(m_RangeDecoder) == 0)
{ {
distance = rep1; if (m_IsRep0LongDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(m_RangeDecoder) == 0)
{
state.UpdateShortRep();
m_OutWindow.PutByte(m_OutWindow.GetByte(rep0));
nowPos64++;
continue;
}
} }
else else
{ {
if (m_IsRepG2Decoders[state.Index].Decode(m_RangeDecoder) == 0) UInt32 distance;
distance = rep2; if (m_IsRepG1Decoders[state.Index].Decode(m_RangeDecoder) == 0)
{
distance = rep1;
}
else else
{ {
distance = rep3; if (m_IsRepG2Decoders[state.Index].Decode(m_RangeDecoder) == 0)
rep3 = rep2; distance = rep2;
else
{
distance = rep3;
rep3 = rep2;
}
rep2 = rep1;
} }
rep2 = rep1; rep1 = rep0;
} rep0 = distance;
rep1 = rep0;
rep0 = distance;
}
len = m_RepLenDecoder.Decode(m_RangeDecoder, posState) + Base.kMatchMinLen;
state.UpdateRep();
}
else
{
rep3 = rep2;
rep2 = rep1;
rep1 = rep0;
len = Base.kMatchMinLen + m_LenDecoder.Decode(m_RangeDecoder, posState);
state.UpdateMatch();
uint posSlot = m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(m_RangeDecoder);
if (posSlot >= Base.kStartPosModelIndex)
{
int numDirectBits = (int)((posSlot >> 1) - 1);
rep0 = ((2 | (posSlot & 1)) << numDirectBits);
if (posSlot < Base.kEndPosModelIndex)
rep0 += BitTreeDecoder.ReverseDecode(m_PosDecoders,
rep0 - posSlot - 1, m_RangeDecoder, numDirectBits);
else
{
rep0 += (m_RangeDecoder.DecodeDirectBits(
numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits);
rep0 += m_PosAlignDecoder.ReverseDecode(m_RangeDecoder);
} }
len = m_RepLenDecoder.Decode(m_RangeDecoder, posState) + Base.kMatchMinLen;
state.UpdateRep();
} }
else else
rep0 = posSlot; {
rep3 = rep2;
rep2 = rep1;
rep1 = rep0;
len = Base.kMatchMinLen + m_LenDecoder.Decode(m_RangeDecoder, posState);
state.UpdateMatch();
uint posSlot = m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(m_RangeDecoder);
if (posSlot >= Base.kStartPosModelIndex)
{
int numDirectBits = (int)((posSlot >> 1) - 1);
rep0 = ((2 | (posSlot & 1)) << numDirectBits);
if (posSlot < Base.kEndPosModelIndex)
rep0 += BitTreeDecoder.ReverseDecode(m_PosDecoders,
rep0 - posSlot - 1, m_RangeDecoder, numDirectBits);
else
{
rep0 += (m_RangeDecoder.DecodeDirectBits(
numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits);
rep0 += m_PosAlignDecoder.ReverseDecode(m_RangeDecoder);
}
}
else
rep0 = posSlot;
}
if (rep0 >= m_OutWindow.TrainSize + nowPos64 || rep0 >= m_DictionarySizeCheck)
{
if (rep0 == 0xFFFFFFFF)
break;
throw new DataErrorException();
}
m_OutWindow.CopyBlock(rep0, len);
nowPos64 += len;
} }
if (rep0 >= m_OutWindow.TrainSize + nowPos64 || rep0 >= m_DictionarySizeCheck)
{
if (rep0 == 0xFFFFFFFF)
break;
throw new DataErrorException();
}
m_OutWindow.CopyBlock(rep0, len);
nowPos64 += len;
} }
} }
} }
catch (OperationCanceledException)
{
}
m_OutWindow.Flush(); m_OutWindow.Flush();
m_OutWindow.ReleaseStream(); m_OutWindow.ReleaseStream();
m_RangeDecoder.ReleaseStream(); m_RangeDecoder.ReleaseStream();
+3 -1
View File
@@ -5,6 +5,7 @@ using System;
namespace SevenZip.Compression.LZMA namespace SevenZip.Compression.LZMA
{ {
using RangeCoder; using RangeCoder;
using System.Threading;
public class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties public class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
{ {
@@ -1271,7 +1272,7 @@ namespace SevenZip.Compression.LZMA
public void Code(System.IO.Stream inStream, System.IO.Stream outStream, public void Code(System.IO.Stream inStream, System.IO.Stream outStream,
Int64 inSize, Int64 outSize, ICodeProgress progress) Int64 inSize, Int64 outSize, ICodeProgress progress, CancellationToken? token = null)
{ {
_needReleaseMFStream = false; _needReleaseMFStream = false;
try try
@@ -1279,6 +1280,7 @@ namespace SevenZip.Compression.LZMA
SetStreams(inStream, outStream, inSize, outSize); SetStreams(inStream, outStream, inSize, outSize);
while (true) while (true)
{ {
token?.ThrowIfCancellationRequested();
Int64 processedInSize; Int64 processedInSize;
Int64 processedOutSize; Int64 processedOutSize;
bool finished; bool finished;
+2 -1
View File
@@ -1,6 +1,7 @@
// ICoder.h // ICoder.h
using System; using System;
using System.Threading;
namespace SevenZip namespace SevenZip
{ {
@@ -58,7 +59,7 @@ namespace SevenZip
/// if input stream is not valid /// if input stream is not valid
/// </exception> /// </exception>
void Code(System.IO.Stream inStream, System.IO.Stream outStream, void Code(System.IO.Stream inStream, System.IO.Stream outStream,
Int64 inSize, Int64 outSize, ICodeProgress progress); Int64 inSize, Int64 outSize, ICodeProgress progress, CancellationToken? token = null);
}; };
/* /*
+2
View File
@@ -34,6 +34,7 @@ namespace DiscUtils.Fat
internal FatFileSystemOptions() internal FatFileSystemOptions()
{ {
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
FileNameEncoding = Encoding.GetEncoding(437); FileNameEncoding = Encoding.GetEncoding(437);
} }
@@ -45,6 +46,7 @@ namespace DiscUtils.Fat
} }
else else
{ {
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
FileNameEncoding = Encoding.GetEncoding(437); FileNameEncoding = Encoding.GetEncoding(437);
} }
} }
+8 -4
View File
@@ -166,7 +166,8 @@ namespace WPinternals
FlowDirection.LeftToRight, FlowDirection.LeftToRight,
new Typeface(PathTextBlock.FontFamily, PathTextBlock.FontStyle, PathTextBlock.FontWeight, PathTextBlock.FontStretch), new Typeface(PathTextBlock.FontFamily, PathTextBlock.FontStyle, PathTextBlock.FontWeight, PathTextBlock.FontStretch),
FontSize, FontSize,
Foreground Foreground,
VisualTreeHelper.GetDpi(this).PixelsPerDip
); );
#endif #endif
@@ -198,7 +199,8 @@ namespace WPinternals
FlowDirection.LeftToRight, FlowDirection.LeftToRight,
new Typeface(CaptionTextBlock.FontFamily, CaptionTextBlock.FontStyle, CaptionTextBlock.FontWeight, CaptionTextBlock.FontStretch), new Typeface(CaptionTextBlock.FontFamily, CaptionTextBlock.FontStyle, CaptionTextBlock.FontWeight, CaptionTextBlock.FontStretch),
FontSize, FontSize,
Foreground Foreground,
VisualTreeHelper.GetDpi(this).PixelsPerDip
); );
#endif #endif
double CaptionWidth = formatted.Width; double CaptionWidth = formatted.Width;
@@ -238,7 +240,8 @@ namespace WPinternals
FlowDirection.LeftToRight, FlowDirection.LeftToRight,
new Typeface(PathTextBlock.FontFamily, PathTextBlock.FontStyle, PathTextBlock.FontWeight, PathTextBlock.FontStretch), new Typeface(PathTextBlock.FontFamily, PathTextBlock.FontStyle, PathTextBlock.FontWeight, PathTextBlock.FontStretch),
FontSize, FontSize,
Foreground Foreground,
VisualTreeHelper.GetDpi(this).PixelsPerDip
); );
#endif #endif
if (NewWidth < 0) if (NewWidth < 0)
@@ -321,7 +324,8 @@ namespace WPinternals
FlowDirection.LeftToRight, FlowDirection.LeftToRight,
new Typeface(PathTextBlock.FontFamily, PathTextBlock.FontStyle, PathTextBlock.FontWeight, PathTextBlock.FontStretch), new Typeface(PathTextBlock.FontFamily, PathTextBlock.FontStyle, PathTextBlock.FontWeight, PathTextBlock.FontStretch),
FontSize, FontSize,
Foreground Foreground,
VisualTreeHelper.GetDpi(this).PixelsPerDip
); );
#endif #endif
+6 -6
View File
@@ -375,18 +375,18 @@ namespace WPinternals
HasChanged = true; HasChanged = true;
} }
if ((NewPartition.PartitionGuid == null) || (NewPartition.PartitionGuid != CurrentPartition.PartitionGuid)) if ((NewPartition.PartitionGuid != Guid.Empty) || (NewPartition.PartitionGuid != CurrentPartition.PartitionGuid))
HasChanged = true; HasChanged = true;
if (NewPartition.PartitionGuid != null) if (NewPartition.PartitionGuid != Guid.Empty)
CurrentPartition.PartitionGuid = NewPartition.PartitionGuid; CurrentPartition.PartitionGuid = NewPartition.PartitionGuid;
if (CurrentPartition.PartitionGuid == null) if (CurrentPartition.PartitionGuid != Guid.Empty)
CurrentPartition.PartitionGuid = Guid.NewGuid(); CurrentPartition.PartitionGuid = Guid.NewGuid();
if ((NewPartition.PartitionTypeGuid == null) || (NewPartition.PartitionTypeGuid != CurrentPartition.PartitionTypeGuid)) if ((NewPartition.PartitionTypeGuid != Guid.Empty) || (NewPartition.PartitionTypeGuid != CurrentPartition.PartitionTypeGuid))
HasChanged = true; HasChanged = true;
if (NewPartition.PartitionTypeGuid != null) if (NewPartition.PartitionTypeGuid != Guid.Empty)
CurrentPartition.PartitionTypeGuid = NewPartition.PartitionTypeGuid; CurrentPartition.PartitionTypeGuid = NewPartition.PartitionTypeGuid;
if (CurrentPartition.PartitionTypeGuid == null) if (CurrentPartition.PartitionTypeGuid != Guid.Empty)
CurrentPartition.PartitionTypeGuid = Guid.NewGuid(); CurrentPartition.PartitionTypeGuid = Guid.NewGuid();
for (int i = this.Partitions.Count - 1; i >= 0; i--) for (int i = this.Partitions.Count - 1; i >= 0; i--)
+11 -3
View File
@@ -92,6 +92,8 @@ namespace WPinternals
private Stream stream; private Stream stream;
private bool LeaveOpen; private bool LeaveOpen;
private Thread WorkThread; private Thread WorkThread;
private CancellationTokenSource source;
private CancellationToken token;
public LZMACompressionStream(Stream stream, CompressionMode mode, bool LeaveOpen, int DictionarySize, int PosStateBits, public LZMACompressionStream(Stream stream, CompressionMode mode, bool LeaveOpen, int DictionarySize, int PosStateBits,
int LitContextBits, int LitPosBits, int Algorithm, int NumFastBytes, string MatchFinder, bool EndMarker) int LitContextBits, int LitPosBits, int Algorithm, int NumFastBytes, string MatchFinder, bool EndMarker)
@@ -99,6 +101,8 @@ namespace WPinternals
this.stream = stream; this.stream = stream;
this.LeaveOpen = LeaveOpen; this.LeaveOpen = LeaveOpen;
BufferStream = new PumpStream(); BufferStream = new PumpStream();
source = new CancellationTokenSource();
token = source.Token;
if (mode == CompressionMode.Compress) if (mode == CompressionMode.Compress)
{ {
@@ -130,14 +134,14 @@ namespace WPinternals
private void Encode() private void Encode()
{ {
Encoder.Code(BufferStream, stream, -1, -1, null); Encoder.Code(BufferStream, stream, -1, -1, null, token);
if (LeaveOpen == false) if (LeaveOpen == false)
stream.Close(); stream.Close();
} }
private void Decode() private void Decode()
{ {
Decoder.Code(stream, BufferStream, -1, -1, null); Decoder.Code(stream, BufferStream, -1, -1, null, token);
BufferStream.Close(); BufferStream.Close();
if (LeaveOpen == false) if (LeaveOpen == false)
stream.Close(); stream.Close();
@@ -148,7 +152,11 @@ namespace WPinternals
if (Encoder != null) if (Encoder != null)
BufferStream.Close(); BufferStream.Close();
else if (WorkThread.IsAlive) else if (WorkThread.IsAlive)
WorkThread.Abort(); {
if (source != null)
source.Cancel();
WorkThread.Join();
}
} }
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
+1 -12
View File
@@ -118,14 +118,12 @@ namespace WPinternals
[DllImport( [DllImport(
KERNEL32, KERNEL32,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern bool CloseHandle(IntPtr handle); internal static extern bool CloseHandle(IntPtr handle);
[DllImport( [DllImport(
ADVAPI32, ADVAPI32,
CharSet = CharSet.Unicode, CharSet = CharSet.Unicode,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern bool AdjustTokenPrivileges( internal static extern bool AdjustTokenPrivileges(
[In] SafeTokenHandle TokenHandle, [In] SafeTokenHandle TokenHandle,
[In] bool DisableAllPrivileges, [In] bool DisableAllPrivileges,
@@ -138,7 +136,6 @@ namespace WPinternals
ADVAPI32, ADVAPI32,
CharSet = CharSet.Auto, CharSet = CharSet.Auto,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern internal static extern
bool RevertToSelf(); bool RevertToSelf();
@@ -147,7 +144,6 @@ namespace WPinternals
EntryPoint = "LookupPrivilegeValueW", EntryPoint = "LookupPrivilegeValueW",
CharSet = CharSet.Auto, CharSet = CharSet.Auto,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern internal static extern
bool LookupPrivilegeValue( bool LookupPrivilegeValue(
[In] string lpSystemName, [In] string lpSystemName,
@@ -158,7 +154,6 @@ namespace WPinternals
KERNEL32, KERNEL32,
CharSet = CharSet.Auto, CharSet = CharSet.Auto,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern internal static extern
IntPtr GetCurrentProcess(); IntPtr GetCurrentProcess();
@@ -166,7 +161,6 @@ namespace WPinternals
KERNEL32, KERNEL32,
CharSet = CharSet.Auto, CharSet = CharSet.Auto,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern internal static extern
IntPtr GetCurrentThread(); IntPtr GetCurrentThread();
@@ -174,7 +168,6 @@ namespace WPinternals
ADVAPI32, ADVAPI32,
CharSet = CharSet.Unicode, CharSet = CharSet.Unicode,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern internal static extern
bool OpenProcessToken( bool OpenProcessToken(
[In] IntPtr ProcessToken, [In] IntPtr ProcessToken,
@@ -185,7 +178,6 @@ namespace WPinternals
(ADVAPI32, (ADVAPI32,
CharSet = CharSet.Unicode, CharSet = CharSet.Unicode,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern internal static extern
bool OpenThreadToken( bool OpenThreadToken(
[In] IntPtr ThreadToken, [In] IntPtr ThreadToken,
@@ -197,7 +189,6 @@ namespace WPinternals
(ADVAPI32, (ADVAPI32,
CharSet = CharSet.Unicode, CharSet = CharSet.Unicode,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern internal static extern
bool DuplicateTokenEx( bool DuplicateTokenEx(
[In] SafeTokenHandle ExistingToken, [In] SafeTokenHandle ExistingToken,
@@ -211,7 +202,6 @@ namespace WPinternals
(ADVAPI32, (ADVAPI32,
CharSet = CharSet.Unicode, CharSet = CharSet.Unicode,
SetLastError = true)] SetLastError = true)]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
internal static extern internal static extern
bool SetThreadToken( bool SetThreadToken(
[In] IntPtr Thread, [In] IntPtr Thread,
@@ -301,8 +291,7 @@ namespace WPinternals
} }
[DllImport(NativeMethods.KERNEL32, SetLastError = true), [DllImport(NativeMethods.KERNEL32, SetLastError = true),
SuppressUnmanagedCodeSecurity, SuppressUnmanagedCodeSecurity]
ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern bool CloseHandle(IntPtr handle); private static extern bool CloseHandle(IntPtr handle);
override protected bool ReleaseHandle() override protected bool ReleaseHandle()
-20
View File
@@ -20,8 +20,6 @@
using System; using System;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
@@ -93,7 +91,6 @@ namespace WPinternals
// of privilege names to luids // of privilege names to luids
// //
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private static Luid LuidFromPrivilege(string privilege) private static Luid LuidFromPrivilege(string privilege)
{ {
Luid luid; Luid luid;
@@ -104,8 +101,6 @@ namespace WPinternals
// Look up the privilege LUID inside the cache // Look up the privilege LUID inside the cache
// //
RuntimeHelpers.PrepareConstrainedRegions();
try try
{ {
privilegeLock.AcquireReaderLock(Timeout.Infinite); privilegeLock.AcquireReaderLock(Timeout.Infinite);
@@ -206,8 +201,6 @@ namespace WPinternals
} }
} }
RuntimeHelpers.PrepareConstrainedRegions();
try try
{ {
// Open the thread token; if there is no thread token, // Open the thread token; if there is no thread token,
@@ -382,19 +375,16 @@ namespace WPinternals
#endregion #endregion
#region Public methods and properties #region Public methods and properties
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void Enable() public void Enable()
{ {
this.ToggleState(true); this.ToggleState(true);
} }
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void Disable() public void Disable()
{ {
this.ToggleState(false); this.ToggleState(false);
} }
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public void Revert() public void Revert()
{ {
int error = 0; int error = 0;
@@ -413,8 +403,6 @@ namespace WPinternals
// This code must be eagerly prepared and non-interruptible. // This code must be eagerly prepared and non-interruptible.
RuntimeHelpers.PrepareConstrainedRegions();
try try
{ {
// The payload is entirely in the finally block // The payload is entirely in the finally block
@@ -492,8 +480,6 @@ namespace WPinternals
Privilege p = new Privilege(privilege); Privilege p = new Privilege(privilege);
RuntimeHelpers.PrepareConstrainedRegions();
try try
{ {
if (enabled) if (enabled)
@@ -520,7 +506,6 @@ namespace WPinternals
#endregion #endregion
#region Private implementation #region Private implementation
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
private void ToggleState(bool enable) private void ToggleState(bool enable)
{ {
int error = 0; int error = 0;
@@ -542,8 +527,6 @@ namespace WPinternals
// Need to make this block of code non-interruptible so that it would preserve // Need to make this block of code non-interruptible so that it would preserve
// consistency of thread oken state even in the face of catastrophic exceptions // consistency of thread oken state even in the face of catastrophic exceptions
RuntimeHelpers.PrepareConstrainedRegions();
try try
{ {
// The payload is entirely in the finally block // The payload is entirely in the finally block
@@ -635,11 +618,8 @@ namespace WPinternals
} }
} }
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private void Reset() private void Reset()
{ {
RuntimeHelpers.PrepareConstrainedRegions();
try try
{ {
// Payload is in the finally block // Payload is in the finally block
+16 -946
View File
File diff suppressed because it is too large Load Diff