Skip to content

Commit

Permalink
Fix compiler errors (on mono) (de4dot#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
PoroCYon authored and wtfsck committed Jan 5, 2017
1 parent cf19456 commit 126758f
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 58 deletions.
2 changes: 1 addition & 1 deletion de4dot.blocks/cflow/InstructionEmulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ void Emulate_Isinst(Instruction instr) {
}

void Emulate_Ldfld(Instruction instr) {
var val1 = valueStack.Pop();
/*var val1 =*/ valueStack.Pop();
EmulateLoadField(instr.Operand as IField);
}

Expand Down
9 changes: 7 additions & 2 deletions de4dot.code/de4dot.code.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,14 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>mkdir "..\$(OutDir)..\LICENSES"
<PostBuildEvent Condition="'$(OS)' != 'Unix'">mkdir "..\$(OutDir)..\LICENSES"
copy "$(SolutionDir)LICENSE*.txt" "..\$(OutDir)..\LICENSES"
copy "$(SolutionDir)COPYING" "..\$(OutDir)..\LICENSES"</PostBuildEvent>
<PostBuildEvent Condition="'$(OS)' == 'Unix'">
mkdir -p "../$(OutDir)../LICENSES/"
cp "$(SolutionDir)LICENSE"*.txt "../$(OutDir)../LICENSES/"
cp "$(SolutionDir)COPYING" "../$(OutDir)../LICENSES/"
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand All @@ -418,4 +423,4 @@ copy "$(SolutionDir)COPYING" "..\$(OutDir)..\LICENSES"</PostBuildEvent>
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Convert(MethodDef cilMethod, CsvmMethodData csvmMethod) {
vmIndexToCil.Clear();

var newInstructions = ReadInstructions(cilMethod, csvmMethod);
var newLocals = ReadLocals(cilMethod, csvmMethod);
/*var newLocals =*/ ReadLocals(cilMethod, csvmMethod);
var newExceptions = ReadExceptions(cilMethod, csvmMethod);

FixInstructionOperands(newInstructions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ Instruction Handler_Rem_Un(BinaryReader reader) {
}

Instruction Handler_Ret(BinaryReader reader) {
var method = resolver.ResolveToken(reader.ReadUInt32(), gpContext) as IMethod;
/*var method =*/ resolver.ResolveToken(reader.ReadUInt32(), gpContext) /*as IMethod*/;
return OpCodes.Ret.ToInstruction();
}

Expand Down Expand Up @@ -486,7 +486,7 @@ Instruction Handler_Stfld_Stsfld(BinaryReader reader) {

Instruction Handler_Stloc(BinaryReader reader) {
ushort loc = reader.ReadUInt16();
var etype = (ElementType)reader.ReadInt32();
/*var etype = (ElementType)*/reader.ReadInt32();
return new Instruction(OpCodes.Stloc, new LocalOperand(loc));
}

Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/Babel_NET/ImageReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ enum TypeId : byte {
Dictionary<string, int> methodOffsets;
List<TypeSig> typeRefs;
MemberRefConverter memberRefConverter;
IDeobfuscatorContext deobfuscatorContext;
//IDeobfuscatorContext deobfuscatorContext;

public ImageReader(IDeobfuscatorContext deobfuscatorContext, ModuleDefMD module, byte[] data) {
this.deobfuscatorContext = deobfuscatorContext;
//this.deobfuscatorContext = deobfuscatorContext;
this.module = module;
this.reader = MemoryImageStream.Create(data);
this.memberRefConverter = new MemberRefConverter(module);
Expand Down
6 changes: 3 additions & 3 deletions de4dot.code/deobfuscators/Babel_NET/ResourceDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ bool GetKeyIv(byte[] headerData, out byte[] key, out byte[] iv) {

// 3.0 - 3.5 don't have this field
if (headerData[(int)reader.BaseStream.Position] != 8) {
var license = reader.ReadString();
/*var license =*/ reader.ReadString();
}

// 4.2 (and earlier?) always compress the data
Expand Down Expand Up @@ -189,10 +189,10 @@ byte[] GetHeaderData(byte[] encryptedData, ref int index) {
bool GetKeyIv(byte[] headerData, out byte[] key, out byte[] iv) {
var reader = new BinaryReader(new MemoryStream(headerData));

var license = reader.ReadString();
/*var license =*/ reader.ReadString();
bool isCompressed = reader.ReadBoolean();

var unkData = reader.ReadBytes(reader.ReadInt32());
/*var unkData =*/ reader.ReadBytes(reader.ReadInt32());

bool hasEmbeddedKey = reader.ReadBoolean();

Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/deobfuscators/CodeVeil/MethodsDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public bool Decrypt(byte[] fileData, ref DumpedMethods dumpedMethods) {
DumpedMethods CreateDumpedMethods(MyPEImage peImage, byte[] fileData, byte[] methodsData) {
var dumpedMethods = new DumpedMethods();

var methodsDataReader = MemoryImageStream.Create(methodsData);
/*var methodsDataReader =*/ MemoryImageStream.Create(methodsData);
var fileDataReader = MemoryImageStream.Create(fileData);

var methodDef = peImage.MetaData.TablesStream.MethodTable;
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/CodeVeil/ResourceDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ void FindResourceFlags() {
resourceFlagsType = type;
}

static string[] resType_fields = new string[] {
/*static string[] resType_fields = new string[] {
"System.Int32",
"System.Object",
"System.String",
};
};*/
void FindResType() {
if (encryptedResourceReaderTypeDict == null)
return;
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/deobfuscators/CodeVeil/StringDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void DecryptStrings(uint[] key) {

var inflated = DeobUtils.Inflate(decryptedData, 0, decryptedData.Length, true);
var reader = MemoryImageStream.Create(inflated);
int deflatedLength = (int)reader.ReadCompressedUInt32();
/*int deflatedLength = (int)*/reader.ReadCompressedUInt32();
int numStrings = (int)reader.ReadCompressedUInt32();
decryptedStrings = new string[numStrings];
var offsets = new int[numStrings];
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/CodeWall/StringDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ static MethodDef CheckMethodsV30(TypeDef type) {
return null;

MethodDef decrypterMethod = null;
MethodDef cctor = null;
//MethodDef cctor = null;
foreach (var method in type.Methods) {
if (method.Name == ".cctor") {
cctor = method;
//cctor = method;
continue;
}
if (decrypterMethod != null)
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/Confuser/ConstantsFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ protected override bool Deobfuscate(Block block) {
// Convert ldc.r4/r8 followed by conv to the appropriate ldc.i4/i8 instr
if (i + 1 < instrs.Count && (instr.OpCode.Code == Code.Ldc_R4 || instr.OpCode.Code == Code.Ldc_R8)) {
var conv = instrs[i + 1];
int vali32 = instr.OpCode.Code == Code.Ldc_R4 ? (int)(float)instr.Operand : (int)(double)instr.Operand;
/*int vali32 = instr.OpCode.Code == Code.Ldc_R4 ? (int)(float)instr.Operand : (int)(double)instr.Operand;
long vali64 = instr.OpCode.Code == Code.Ldc_R4 ? (long)(float)instr.Operand : (long)(double)instr.Operand;
uint valu32 = instr.OpCode.Code == Code.Ldc_R4 ? (uint)(float)instr.Operand : (uint)(double)instr.Operand;
ulong valu64 = instr.OpCode.Code == Code.Ldc_R4 ? (ulong)(float)instr.Operand : (ulong)(double)instr.Operand;
ulong valu64 = instr.OpCode.Code == Code.Ldc_R4 ? (ulong)(float)instr.Operand : (ulong)(double)instr.Operand;*/
switch (conv.OpCode.Code) {
case Code.Conv_I1:
newInstr = Instruction.CreateLdcI4(instr.OpCode.Code == Code.Ldc_R4 ? (sbyte)(float)instr.Operand : (sbyte)(double)instr.Operand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ byte[] DecryptMethodsData_v14_r57884(MyPEImage peImage, bool hasStrongNameInfo)

int csOffs = (int)peImage.OptionalHeader.StartOffset + 0x40;
Array.Clear(md5SumData, csOffs, 4);
var md5Sum = DeobUtils.Md5Sum(md5SumData);
/*var md5Sum =*/ DeobUtils.Md5Sum(md5SumData);
ulong checkSum = reader.ReadUInt64() ^ lkey0;
if (hasStrongNameInfo) {
int sn = reader.ReadInt32();
Expand Down
3 changes: 2 additions & 1 deletion de4dot.code/deobfuscators/Confuser/Unpacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override string ToString() {
class Unpacker : IVersionProvider {
ModuleDefMD module;
EmbeddedResource mainAsmResource;
uint key0, key1;
uint key0/*, key1*/;
uint entryPointToken;
ConfuserVersion version = ConfuserVersion.Unknown;
MethodDef asmResolverMethod;
Expand Down Expand Up @@ -146,6 +146,7 @@ public void Find(ISimpleDeobfuscator simpleDeobfuscator, IDeobfuscator deob) {
if ((asmResolverMethod = FindAssemblyResolverMethod(entryPoint.DeclaringType)) != null) {
theVersion = ConfuserVersion.v14_r58802;
simpleDeobfuscator.Deobfuscate(asmResolverMethod);
uint key1;
if (!FindKey1(asmResolverMethod, out key1))
return;
}
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/deobfuscators/DeepSea/FieldsRestorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void DeobfuscateNormal(Blocks blocks) {
void FixFieldCtorCalls(Blocks blocks) {
if (blocks.Method.Name != ".ctor")
return;
var instrsToRemove = new List<int>();
//var instrsToRemove = new List<int>();
foreach (var block in blocks.MethodBlocks.GetAllBlocks()) {
var instrs = block.Instructions;
for (int i = 0; i < instrs.Count; i++) {
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/DeepSea/StringDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public string Decrypt(object[] args) {
string DecryptTrial(int magic2, int magic3) {
int offset = magic ^ magic2 ^ magic3;
var keyChar = encryptedData[offset + 1];
int cachedIndex = encryptedData[offset] ^ keyChar;
//int cachedIndex = encryptedData[offset] ^ keyChar;
int numChars = ((keyChar ^ encryptedData[offset + 2]) << 16) + (keyChar ^ encryptedData[offset + 3]);
offset += 4;
var sb = new StringBuilder(numChars);
Expand All @@ -395,7 +395,7 @@ string DecryptRetail3(int magic2, int magic3) {
string DecryptRetail(int magic2, int magic3, int keyCharOffs, int cachedIndexOffs, int flagsOffset, int flag, int keyDispl) {
int offset = magic ^ magic2 ^ magic3;
var keyChar = encryptedData[offset + keyCharOffs];
int cachedIndex = encryptedData[offset + cachedIndexOffs] ^ keyChar;
//int cachedIndex = encryptedData[offset + cachedIndexOffs] ^ keyChar;
int flags = encryptedData[offset + flagsOffset] ^ keyChar;
int numChars = ((flags >> 1) & ~(flag - 1)) | (flags & (flag - 1));
if ((flags & flag) != 0) {
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/Dotfuscator/Deobfuscator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override IDeobfuscator CreateDeobfuscator() {
}

class Deobfuscator : DeobfuscatorBase {
Options options;
//Options options;
string obfuscatorName = "Dotfuscator";

StringDecrypter stringDecrypter;
Expand All @@ -70,7 +70,7 @@ public override string Name {

public Deobfuscator(Options options)
: base(options) {
this.options = options;
//this.options = options;
}

protected override int DetectInternal() {
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/Eazfuscator_NET/Deobfuscator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override IDeobfuscator CreateDeobfuscator() {
}

class Deobfuscator : DeobfuscatorBase {
Options options;
//Options options;
string obfuscatorName = DeobfuscatorInfo.THE_NAME;
bool detectedVersion = false;

Expand All @@ -76,7 +76,7 @@ public override string Name {

public Deobfuscator(Options options)
: base(options) {
this.options = options;
//this.options = options;
}

protected override int DetectInternal() {
Expand Down
6 changes: 3 additions & 3 deletions de4dot.code/deobfuscators/Eazfuscator_NET/StringDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class StringDecrypter : IDisposable {
MethodDef stringMethod;
TypeDef dataDecrypterType;
short s1, s2, s3;
int i1, i2, i3, i4, i5, i6;
int i1, /*i2,*/ i3, i4, i5, i6;
bool checkMinus2;
bool usePublicKeyToken;
int keyLen;
Expand Down Expand Up @@ -734,7 +734,7 @@ bool FindInts(int index) {
if (index < 0)
return false;

i2 = 0;
//i2 = 0;
var instrs = stringMethod.Body.Instructions;

var emu = new InstructionEmulator(stringMethod);
Expand Down Expand Up @@ -792,7 +792,7 @@ bool FindInts(int index) {
foreach (var val in fields.Values) {
if (val == null)
continue;
magic1 = i2 = val.Value;
magic1 = /*i2 =*/ val.Value;
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/Goliath_NET/StringDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public StringDecrypter(ModuleDefMD module)
: base(module) {
}

static string[] requiredFields = new string[] {
/*static string[] requiredFields = new string[] {
"System.Byte[]",
"System.Collections.Generic.Dictionary`2<System.Int32,System.String>",
};
};*/
protected override bool CheckDecrypterType(TypeDef type) {
var fields = type.Fields;
if (fields.Count != 2)
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/ILProtector/Deobfuscator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected override IEnumerable<Option> GetOptionsInternal() {
}

class Deobfuscator : DeobfuscatorBase {
Options options;
//Options options;
string obfuscatorName = DeobfuscatorInfo.THE_NAME;

MainType mainType;
Expand All @@ -77,7 +77,7 @@ public override string Name {

public Deobfuscator(Options options)
: base(options) {
this.options = options;
//this.options = options;
}

protected override int DetectInternal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sealed class DynamicMethodsDecrypter : IDisposable {
Module reflectionModule;
Module reflectionProtectModule;
TypeDef protectMainType;
Type reflectionProtectMainType;
//Type reflectionProtectMainType;
FieldInfo invokerFieldInfo;
ModuleDefMD moduleProtect;
IDecrypter decrypter;
Expand Down Expand Up @@ -630,7 +630,7 @@ public void Initialize() {
throw new ApplicationException("Could not find Protect.MainType");
var invokerField = FindInvokerField(module);

reflectionProtectMainType = reflectionProtectModule.ResolveType(0x02000000 + (int)protectMainType.Rid);
/*reflectionProtectMainType =*/ reflectionProtectModule.ResolveType(0x02000000 + (int)protectMainType.Rid);
invokerFieldInfo = reflectionModule.ResolveField(0x04000000 + (int)invokerField.Rid);

decrypter = CreateDecrypter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static DecryptedMethodInfo[] ReadMethodInfos(byte[] data) {
var toOffset = new Dictionary<DecryptedMethodInfo, int>();
var reader = MemoryImageStream.Create(data);
int numMethods = (int)reader.Read7BitEncodedUInt32();
int totalCodeSize = (int)reader.Read7BitEncodedUInt32();
/*int totalCodeSize = (int)*/reader.Read7BitEncodedUInt32();
var methodInfos = new DecryptedMethodInfo[numMethods];
int offset = 0;
for (int i = 0; i < numMethods; i++) {
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/deobfuscators/MaxtoCode/CryptDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ static Bits CreateKey(byte[] data, int index) {
Bits key1, key2;
CreateKeys(data, index, out key1, out key2);
byte[] newKey = new byte[16 * 6];
byte[] tmpData = new byte[28 * 2];
//byte[] tmpData = new byte[28 * 2];
for (int i = 0; i < 16; i++) {
int rolCount = rots[i];
key1.Rol(rolCount);
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/MaxtoCode/McKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ You should have received a copy of the GNU General Public License

namespace de4dot.code.deobfuscators.MaxtoCode {
class McKey {
PeHeader peHeader;
//PeHeader peHeader;
byte[] data;

public byte this[int index] {
get { return data[index]; }
}

public McKey(MyPEImage peImage, PeHeader peHeader) {
this.peHeader = peHeader;
//this.peHeader = peHeader;
try {
this.data = peImage.ReadBytes(peHeader.GetMcKeyRva(), 0x2000);
}
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/deobfuscators/MaxtoCode/MethodsDecrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ bool InitializeInfos2(IDecrypter decrypter) {
for (int i = 0; i < numMethods; i++, offset += structSize) {
uint methodBodyRva = ReadEncryptedUInt32(offset);
uint totalSize = ReadEncryptedUInt32(offset + 4);
uint methodInstructionRva = ReadEncryptedUInt32(offset + 8);
/*uint methodInstructionRva =*/ ReadEncryptedUInt32(offset + 8);

// Read the method body header and method body (instrs + exception handlers).
// The method body header is always in the first one. The instrs + ex handlers
Expand Down
2 changes: 1 addition & 1 deletion de4dot.code/deobfuscators/QuickLZ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static byte[] Decompress(byte[] inData) {
}

public static byte[] Decompress(byte[] inData, int sig) {
int mode = BitConverter.ToInt32(inData, 4);
/*int mode =*/ BitConverter.ToInt32(inData, 4);
int compressedLength = BitConverter.ToInt32(inData, 8);
int decompressedLength = BitConverter.ToInt32(inData, 12);
bool isDataCompressed = BitConverter.ToInt32(inData, 16) == 1;
Expand Down
4 changes: 2 additions & 2 deletions de4dot.code/deobfuscators/Skater_NET/Deobfuscator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override IDeobfuscator CreateDeobfuscator() {
}

class Deobfuscator : DeobfuscatorBase {
Options options;
//Options options;

StringDecrypter stringDecrypter;
EnumClassFinder enumClassFinder;
Expand All @@ -69,7 +69,7 @@ public override string Name {

public Deobfuscator(Options options)
: base(options) {
this.options = options;
//this.options = options;
StringFeatures = StringFeatures.AllowNoDecryption | StringFeatures.AllowStaticDecryption;
}

Expand Down
Loading

0 comments on commit 126758f

Please sign in to comment.