public ZombieSpawner(PvZProcess process) { mProcess = process; byte[] code = new byte[] { 0x50, //push ebx 0x53, //push eax 0xA1, 0xF9, 0x29, 0x6E, 0x00, //eax, [6E29F9] 0x83, 0xF8, 0x01, //cmp eax, 1 0x75, 0x1F, //je 1Fh 0xFF, 0x35, 0xFD, 0x29, 0x6E, 0x00, //push [6E29FD] 0xFF, 0x35, 0x01, 0x2A, 0x6E, 0x00, //push [6E2A01] 0x8B, 0xC7, //mov eax, edi 0xBB, 0xC0, 0xDD, 0x40, 0x00, //mov ebx, 40DDC0h 0xFF, 0xD3, //call ebx 0xC7, 0x05, 0xF9, 0x29, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, //mov [6E29F9], 0 0x5B, //pop eax 0x58 }; //pop ebx //412A3C //412C0E //412DE0 //412F86 //413059 - 1 //4263D2 //429B90 //42A103 //439181 - MUST KEEP //534E17 mProcess = process; mSpawnerCode = new CodeInjection(0x413D23, 6, code); mSpawnerCode.Process = mProcess; }
public void AllTest() { IBussinesLogicEmployees iBLExternal = null; iBLExternal = (IBussinesLogicEmployees)CodeInjection.Create( new BussinesLogicEmployees(), typeof(IBussinesLogicEmployeesAll)); Employees dsE = null; dsE = iBLExternal.GetEmployees(BussinesLogicEmployees.Delegation.Madrid); Assert.IsNotNull(dsE); Assert.AreEqual(1, CountingCalls.Calls("GetEmployees")); try { dsE = iBLExternal.GetEmployees(BussinesLogicEmployees.Delegation.Paris); } catch { dsE = null; } Assert.IsNull(dsE); Assert.AreEqual(2, CountingCalls.Calls("GetEmployees")); dsE = iBLExternal.GetEmployees(BussinesLogicEmployees.Delegation.London); Assert.IsNotNull(dsE); Assert.AreEqual(3, CountingCalls.Calls("GetEmployees")); }
protected override SyntaxNode Revert(ExpressionSyntax node) { // remove the enclosed initializer such as: MutantContext.TrackValue(()=>initializer); ==> initializer if (node is InvocationExpressionSyntax invocation && CodeInjection.IsContextAccessExpression(invocation.Expression, MutantContextValueTrackName) && invocation.ArgumentList.Arguments.First().Expression is ParenthesizedLambdaExpressionSyntax parenthesized) { return(parenthesized.ExpressionBody); } throw new InvalidOperationException($"Can't extract original expression from {node}"); }
public ExpressionSyntax PlaceValueMarker(ExpressionSyntax node) { if (node is InitializerExpressionSyntax) { // we cannot track array initializer with this construction return(node); } // enclose the expression into a lambda, such as: initializer => MutantContext.TrackValue(()=>initializer); return(SyntaxFactory.InvocationExpression( CodeInjection.GetContextClassAccessExpression(MutantContextValueTrackName), SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList( SyntaxFactory.Argument(SyntaxFactory.ParenthesizedLambdaExpression(node))))) .WithAdditionalAnnotations(Marker)); }
static void Main(string[] args) { //var x = new TempAssemblyInjection__ProxyIMyclassMyClassTest(new MyClassTest(), typeof(IMyclass)); ////x.MyClassTestInterface(); var my = (IMyclass)CodeInjection.Create(new MyClassTest(), typeof(IMyclass)); MethodInfo mf = my.GetType().GetMethod("MyClassTestInterface", new Type[0]); var str = mf.Invoke(my, null); Console.WriteLine(str); my.MyClassTestInterface(); //CodeInjection.InjectHandler(this.target, // Helper.GetMethodFromType(this.target.GetType(), MethodBase.GetCurrentMethod()), // parameters, // Helper.AspectUnion(Helper.GetMethodFromType(this.iface, MethodBase.GetCurrentMethod()).GetCustomAttributes(typeof(AspectAttribute), true))); Console.Read(); }
private void timer1_Tick(object sender, EventArgs e) { gameProcess = Process.GetProcessesByName("thief").FirstOrDefault(); if (gameProcess == null) { injection = null; } else if (injection == null) { CodeInjectionMasterContainer container = new CodeInjectionMasterContainer(); container.AddVariable("IsLoading", 0); container.AddInjectionPoint("LoadStart", gameProcess.MainModule.BaseAddress.ToInt32() + 0x177A0, 6); container.AddWriteToVariable("IsLoading", 1); container.AddByteCode(new byte[] { 0x81, 0xEC, 0x84, 0x0A, 0x00, 0x00 }); container.CloseInjection("LoadStart"); container.AddInjectionPoint("LoadEnd", gameProcess.MainModule.BaseAddress.ToInt32() + 0x18302, 7); container.AddWriteToVariable("IsLoading", 0); container.AddByteCode(new byte[] { 0x8B, 0x8C, 0x24, 0x8C, 0x0A, 0x00, 0x00 }); container.CloseInjection("LoadEnd"); injection = new CodeInjection(gameProcess, container); } }
/// <summary> /// injects a 'using' block with static marker class used by coverage logic. /// </summary> /// <param name="block"></param> /// <returns></returns> public BlockSyntax PlaceStaticContextMarker(BlockSyntax block) => SyntaxFactory.Block( SyntaxFactory.UsingStatement(null, CodeInjection.GetContextClassConstructor(), block)).WithAdditionalAnnotations(Marker);