Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions NETReactorSlayer.Core/Helper/EncryptedResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ private IDecrypter GetDecrypter()
if (DecrypterV4.CouldBeResourceDecrypter(DecrypterMethod, localTypes, AdditionalTypes))
return new DecrypterV4(DecrypterMethod);

return DecrypterV2.CouldBeResourceDecrypter(localTypes, AdditionalTypes)
? new DecrypterV2(DecrypterMethod)
: null;
if (DecrypterV2.CouldBeResourceDecrypter(localTypes, AdditionalTypes))
return new DecrypterV2(DecrypterMethod);

return null;
}

public static bool IsKnownDecrypter(MethodDef method, IList<string> additionalTypes, bool checkResource)
Expand Down Expand Up @@ -427,12 +428,30 @@ private bool FindStartEnd(IList<Instruction> instrs, out int startIndex, out int
var i = 0;
while (i + 8 < instrs.Count)
{
int newEndIndex = -1;

if (instrs[i].OpCode.Code.Equals(Code.Conv_R_Un) &&
instrs[i + 1].OpCode.Code.Equals(Code.Conv_R8) &&
instrs[i + 2].OpCode.Code.Equals(Code.Conv_U4) &&
instrs[i + 3].OpCode.Code.Equals(Code.Add))
{
var newEndIndex = i + 3;
newEndIndex = i + 3;
}

if (newEndIndex < 0)
{
if (instrs[i].OpCode.Code.Equals(Code.Add) &&
instrs[i + 1].OpCode.Code.Equals(Code.Stloc_S) &&
instrs[i + 2].OpCode.Code.Equals(Code.Ldloc_S) &&
instrs[i + 3].OpCode.Code.Equals(Code.Ldloc_S) &&
instrs[i + 4].OpCode.Code.Equals(Code.Ldc_I4_1))
{
newEndIndex = i;
}
}

if (newEndIndex >= 0)
{
var newStartIndex = -1;
for (var x = newEndIndex; x > 0; x--)
if (instrs[x].OpCode.FlowControl != FlowControl.Next)
Expand Down Expand Up @@ -851,12 +870,30 @@ private bool FindStartEnd(IList<Instruction> instrs, out int startIndex, out int
var i = 0;
while (i + 8 < instrs.Count)
{
int newEndIndex = -1;

if (instrs[i].OpCode.Code.Equals(Code.Conv_R_Un) &&
instrs[i + 1].OpCode.Code.Equals(Code.Conv_R8) &&
instrs[i + 2].OpCode.Code.Equals(Code.Conv_U4) &&
instrs[i + 3].OpCode.Code.Equals(Code.Add))
{
var newEndIndex = i + 3;
newEndIndex = i + 3;
}

if (newEndIndex < 0)
{
if (instrs[i].OpCode.Code.Equals(Code.Add) &&
instrs[i + 1].OpCode.Code.Equals(Code.Stloc_S) &&
instrs[i + 2].OpCode.Code.Equals(Code.Ldloc_S) &&
instrs[i + 3].OpCode.Code.Equals(Code.Ldloc_S) &&
instrs[i + 4].OpCode.Code.Equals(Code.Ldc_I4_1))
{
newEndIndex = i;
}
}

if (newEndIndex >= 0)
{
var newStartIndex = -1;
for (var x = newEndIndex; x > 0; x--)
if (instrs[x].OpCode.FlowControl != FlowControl.Next)
Expand Down
7 changes: 6 additions & 1 deletion NETReactorSlayer.Core/Stages/Cleaner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ You should have received a copy of the GNU General Public License
along with NETReactorSlayer. If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using de4dot.blocks;
Expand Down Expand Up @@ -97,7 +98,11 @@ private void RemoveObfuscatorTypes()
if (Context.Options.KeepObfuscatorTypes)
return;
foreach (var method in MethodsToRemove)
try { method.DeclaringType.Remove(method); } catch { }
try
{
method.DeclaringType.Remove(method);
}
catch { }

foreach (var typeDef in TypesToRemove.Select(type => type.ResolveTypeDef()))
try
Expand Down