/// <summary>Constructor.</summary> /// <param name="targetIORef"> /// A reference to the <see cref="Target"/> object that will be used to read the target process' memory space. /// This <see cref="Target"/> MUST be attached to a process, as it will be used in this constructor method to read the process' /// memory and keep a snapshot of the original bytes at the given 'branchPoint' for restoring their values, /// whenever <see cref="MemoryAlterationX86BranchInstruction.SetEnabled{TMemoryAlterationID, TCodeCave, TVariable}(Injector{TMemoryAlterationID, TCodeCave, TVariable}, bool)"/> is called /// to deactivate a memory alteration. /// </param> /// <param name="branchPoint">The address of the instruction(s) that will be replaced by the branching instruction.</param> /// <param name="branchTarget">The address where the branching instruction will make the target application's code flow to.</param> /// <param name="instructionType">The type of branching instruction to be generated.</param> /// <param name="instructionSize">The size of the instruction(s) that will be replaced with the generated instruction (and some NOP instructions, whenever paddings are necessary).</param> public MemoryAlterationX86BranchInstruction(Target targetIORef, MemoryAddress branchPoint, MemoryAddress branchTarget, EX86BranchInstructionType instructionType, int instructionSize) : base(targetIORef, branchPoint, instructionSize) { m_instructionType = instructionType; m_branchTarget = branchTarget; }
/// <summary>Constructor.</summary> /// <param name="instructionType">The specific type of branch instruction to be generated.</param> /// <param name="targetAddress">The address to where the branch will divert the target process' execution flow.</param> public CodeCaveArtifactX86BranchInstruction(EX86BranchInstructionType instructionType, MemoryAddress targetAddress) { m_branchInstructionType = instructionType; m_targetAddress = targetAddress; }
/// <summary> /// Adds the bytes corresponding to an x86 branch instruction to the code cave being built. /// This effectivelly adds a <see cref="CodeCaveArtifactX86BranchInstruction{TMemoryAlterationSetID, TCodeCave, TVariable}"/> /// artifact to the list of generated artifacts. /// </summary> /// <param name="instructionType">The type of branch instruction to be generated.</param> /// <param name="targetAddress">The target address of the branching instruction.</param> /// <returns>Returns a reference to the object used to call the method.</returns> public CodeCaveBuilder <TMemoryAlterationSetID, TCodeCave, TVariable> X86Branch(EX86BranchInstructionType instructionType, MemoryAddress targetAddress) { m_artifacts.Add(new CodeCaveArtifactX86BranchInstruction <TMemoryAlterationSetID, TCodeCave, TVariable>(instructionType, targetAddress)); return(this); }