예제 #1
0
        public void Activate()
        {
            //Backup the old values
            mOldValues = mProcess.GetBytes((int)mAddress, mNewValues.Length);

            //Write the new values
            mProcess.WriteBytes((int)mAddress, mNewValues);
        }
예제 #2
0
        private void Swap()
        {
            //Get the values from both addresses
            byte[] bufA = mProcess.GetBytes((int)mAddressA, mCount);
            byte[] bufB = mProcess.GetBytes((int)mAddressB, mCount);

            //Write them back but swapped
            mProcess.WriteBytes((int)mAddressA, bufB);
            mProcess.WriteBytes((int)mAddressB, bufA);
        }
예제 #3
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);
        }
예제 #4
0
        public static uint InjectCode(AppProcess process, uint address, int replacedInstructionSize, byte[] newCode)
        {
            if (replacedInstructionSize < 5)
            {
                throw new Exception("Replaced instruction size much be greater than 5.");
            }

            //Allocate the memory required
            uint allocatedMem = process.AllocateMemory((uint)(newCode.Length + replacedInstructionSize + JMPSize));

            //Write the new code in the allocated memory
            process.WriteBytes((int)allocatedMem, newCode);

            //Copy the old code
            CopyInstructions(process, address, allocatedMem + (uint)newCode.Length, replacedInstructionSize);

            //Write jump at the end of the allocated memory
            WriteJump(process, allocatedMem + (uint)newCode.Length + (uint)replacedInstructionSize, address + (uint)replacedInstructionSize);

            //Write jump address
            WriteJump(process, address, allocatedMem);

            //Write nops to be clean
            WriteNOPs(process, address + JMPSize, replacedInstructionSize - JMPSize);

            return(allocatedMem);
        }
예제 #5
0
        public static void WriteNOPs(AppProcess process, uint address, int count)
        {
            if (count <= 0)
            {
                return;
            }

            byte[] nops = new byte[count];
            for (int i = 0; i < count; i++)
            {
                nops[i] = NOP;
            }

            process.WriteBytes((int)address, nops);
        }
예제 #6
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);
        }
예제 #7
0
 public static void CopyInstructions(AppProcess process, uint srcAddress, uint destAddress, int size)
 {
     byte[] instructions = process.GetBytes((int)srcAddress, size);
     process.WriteBytes((int)destAddress, instructions);
 }