Fix block signature in switch deobfuscator

This commit is contained in:
Harry Stoltz
2024-12-30 14:37:40 +00:00
parent da95fd4737
commit e87f40930d
8 changed files with 7 additions and 7 deletions
@@ -26,7 +26,7 @@ namespace UnConfuserEx.Protections.AntiDebug
{
var cctor = module.GlobalType.FindStaticConstructor();
if (cctor == null || !(cctor.HasBody))
if (cctor == null || !(cctor.HasBody) || cctor.Body.Instructions.Count == 0)
return false;
IList<Instruction> instrs;
@@ -19,7 +19,7 @@ namespace UnConfuserEx.Protections.AntiDump
{
var cctor = module.GlobalType.FindStaticConstructor();
if (cctor == null || !(cctor.HasBody))
if (cctor == null || !(cctor.HasBody) || cctor.Body.Instructions.Count == 0)
return false;
IList<Instruction> instrs;
@@ -215,7 +215,7 @@ namespace UnConfuserEx.Protections
{
var cctor = module.GlobalType.FindStaticConstructor();
if (cctor == null || !(cctor.HasBody))
if (cctor == null || !(cctor.HasBody) || cctor.Body.Instructions.Count == 0)
return null;
IList<Instruction> instrs;
@@ -35,7 +35,7 @@ namespace UnConfuserEx.Protections
{
var cctor = module.GlobalType.FindStaticConstructor();
if (cctor == null || !(cctor.HasBody))
if (cctor == null || !(cctor.HasBody) || cctor.Body.Instructions.Count == 0)
return false;
IList<Instruction> instrs;
@@ -145,6 +145,7 @@ namespace UnConfuserEx.Protections.ControlFlow
processedCount++;
}
else if (block.Instructions.Count >= 5 &&
block.Instructions[^1].OpCode == OpCodes.Xor &&
block.Instructions[^2].IsLdcI4() &&
block.Instructions[^4].IsLdcI4())
{
@@ -35,7 +35,7 @@ namespace UnConfuserEx.Protections
{
var cctor = module.GlobalType.FindStaticConstructor();
if (cctor == null || !(cctor.HasBody))
if (cctor == null || !(cctor.HasBody) || cctor.Body.Instructions.Count == 0)
return false;
IList<Instruction> instrs;
-1
View File
@@ -100,7 +100,6 @@ namespace UnConfuserEx
else
{
NativeModuleWriterOptions writerOptions = new NativeModuleWriterOptions(module, true);
//writerOptions.MetadataOptions.Flags = MetadataFlags.PreserveAll;
module.NativeWrite(newPath, writerOptions);
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net9.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>True</UseWindowsForms>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>