Example #1
0
        public void Activate()
        {
            //Backup the old code
            mOldCode = mProcess.GetBytes((int)mAddress, mReplacedInstructionSize);

            //Write the new code
            mProcess.WriteBytes((int)mAddress, mNewCode);

            //Write any additional NOPs
            Hack.WriteNOPs(mProcess, mAddress + (uint)mNewCode.Length, mReplacedInstructionSize - mNewCode.Length);
        }
Example #2
0
        public void Activate()
        {
            //Allocate the memory required
            mAllocatedMemory = mProcess.AllocateMemory((uint)(mNewCode.Length + mReplacedInstructionSize + Hack.JMPSize));
            if (mAllocatedMemory == 0)
            {
                throw new Exception();
            }

            //Write the new code in the allocated memory
            mProcess.WriteBytes((int)mAllocatedMemory, mNewCode);

            //Copy the old code
            Hack.CopyInstructions(mProcess, mAddress, mAllocatedMemory + (uint)mNewCode.Length, mReplacedInstructionSize);

            //Write jump at the end of the allocated memory
            Hack.WriteJump(mProcess, mAllocatedMemory + (uint)mNewCode.Length + (uint)mReplacedInstructionSize, mAddress + (uint)mReplacedInstructionSize);

            //Write jump address
            Hack.WriteJump(mProcess, mAddress, mAllocatedMemory);

            //Write nops to be clean
            Hack.WriteNOPs(mProcess, mAddress + Hack.JMPSize, mReplacedInstructionSize - Hack.JMPSize);
        }