本文整理匯總了C#中Mono.Cecil.AssemblyDefinition.GetField方法的典型用法代碼示例。如果您正苦於以下問題:C# AssemblyDefinition.GetField方法的具體用法?C# AssemblyDefinition.GetField怎麽用?C# AssemblyDefinition.GetField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mono.Cecil.AssemblyDefinition
的用法示例。
在下文中一共展示了AssemblyDefinition.GetField方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TerraHax_onHook
void TerraHax_onHook(AssemblyDefinition asm)
{
#region Lighting
asm.GetMethod("Lighting", "LightColor").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(typeof(TerraHax).GetField("fullbright"))),
Instruction.Create(OpCodes.Brfalse, asm.GetMethod("Lighting", "LightColor").Body.Instructions[0]),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight")),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "wetLightR")),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight2"))
);
asm.GetMethod("Lighting", "LightColorG").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(typeof(TerraHax).GetField("fullbright"))),
Instruction.Create(OpCodes.Brfalse, asm.GetMethod("Lighting", "LightColorG").Body.Instructions[0]),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight")),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "wetLightR")),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight2"))
);
asm.GetMethod("Lighting", "LightColorB").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(typeof(TerraHax).GetField("fullbright"))),
Instruction.Create(OpCodes.Brfalse, asm.GetMethod("Lighting", "LightColorB").Body.Instructions[0]),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight")),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "wetLightR")),
Instruction.Create(OpCodes.Ldc_R4, 1f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight2"))
);
asm.GetMethod("Lighting", "LightColor2").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(typeof(TerraHax).GetField("fullbright"))),
Instruction.Create(OpCodes.Brfalse, asm.GetMethod("Lighting", "LightColor2").Body.Instructions[0]),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight")),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "wetLightR")),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight2"))
);
asm.GetMethod("Lighting", "LightColorG2").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(typeof(TerraHax).GetField("fullbright"))),
Instruction.Create(OpCodes.Brfalse, asm.GetMethod("Lighting", "LightColorG2").Body.Instructions[0]),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight")),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "wetLightR")),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight2"))
);
asm.GetMethod("Lighting", "LightColorB2").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(typeof(TerraHax).GetField("fullbright"))),
Instruction.Create(OpCodes.Brfalse, asm.GetMethod("Lighting", "LightColorB2").Body.Instructions[0]),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight")),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "wetLightR")),
Instruction.Create(OpCodes.Ldc_R4, 0f),
Instruction.Create(OpCodes.Stsfld, asm.GetField("Lighting", "negLight2"))
);
#endregion
#region Player
Instruction getItem = asm.GetMethod("Player", "GetItem").Body.Instructions[0];
asm.GetMethod("Player", "GetItem").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldarg_1),
Instruction.Create(OpCodes.Ldsfld, asm.GetField("Main", "myPlayer")),
Instruction.Create(OpCodes.Bne_Un, getItem),
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(GetField("pickupItems"))),
Instruction.Create(OpCodes.Brfalse, getItem),
Instruction.Create(OpCodes.Newobj, asm.GetMethod("Item", ".ctor")),
Instruction.Create(OpCodes.Ret)
);
Instruction getHurt = asm.GetMethod("Player", "Hurt").Body.Instructions[0];
asm.GetMethod("Player", "Hurt").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldarg_0),
Instruction.Create(OpCodes.Ldfld, asm.GetField("Player", "whoAmi")),
Instruction.Create(OpCodes.Ldsfld, asm.GetField("Main", "myPlayer")),
Instruction.Create(OpCodes.Bne_Un, getHurt),
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(GetField("godMode"))),
Instruction.Create(OpCodes.Brfalse, getHurt),
Instruction.Create(OpCodes.Ldc_R8, 0.0),
Instruction.Create(OpCodes.Ret)
);
Instruction killMe = asm.GetMethod("Player", "KillMe").Body.Instructions[0];
asm.GetMethod("Player", "KillMe").Body.GetILProcessor().Insert(Target.START,
Instruction.Create(OpCodes.Ldarg_0),
Instruction.Create(OpCodes.Ldfld, asm.GetField("Player", "whoAmi")),
Instruction.Create(OpCodes.Ldsfld, asm.GetField("Main", "myPlayer")),
Instruction.Create(OpCodes.Bne_Un, killMe),
Instruction.Create(OpCodes.Ldsfld, asm.MainModule.Import(GetField("godMode"))),
Instruction.Create(OpCodes.Brfalse, killMe),
Instruction.Create(OpCodes.Ret)
);
#endregion
}