示例#1
0
        static Assembly Assembly_load(byte[] data)
        {
            Load load = ILEngine.CreateMethod <Load>(new Instruction(OpCodes.Ldarg_0),
                                                     new Instruction(OpCodes.Call, typeof(Assembly).GetMethod("Load", new Type[] { typeof(byte[]) })),
                                                     new Instruction(OpCodes.Ret));

            return(load(data));
        }
示例#2
0
        static byte[] XorData(byte[] data, byte[] key)
        {
            Xor xor = ILEngine.CreateMethod <Xor>(new Instruction(OpCodes.Ldarg_0),
                                                  new Instruction(OpCodes.Ldarg_1),
                                                  new Instruction(OpCodes.Xor),
                                                  new Instruction(OpCodes.Ret));

            Mod mod = ILEngine.CreateMethod <Mod>(new Instruction(OpCodes.Ldarg_0),
                                                  new Instruction(OpCodes.Ldarg_1),
                                                  new Instruction(OpCodes.Rem),
                                                  new Instruction(OpCodes.Ret));

            byte[] enc = data.Clone() as byte[];
            for (int i = 0; i < enc.Length; i++)
            {
                enc[i] = xor(enc[i], key[mod(i, key.Length)]);
            }
            return(enc);
        }