/// <summary> Restores the original code inside the method code. (Does not remove the hook, call Remove() for that!) </summary> public void SetOriCodeRestore() { if (oriCodeSetting != OriCodeSetting.Enabled) { Process.WriteBytes(oriCodeAddress, oriCode, Length); oriCodeSetting = OriCodeSetting.Enabled; } }
/// <summary> Nops out the original code inside the method code. </summary> public void SetOriCodeSkip() { if (oriCodeSetting != OriCodeSetting.Skip) { Process.Nop(oriCodeAddress, Length); oriCodeSetting = OriCodeSetting.Skip; } }
/// <summary> Replaces the original code with a return instruction inside the method code </summary> /// <param name="stackCleanupParams"> Number of parameters which should be considered in the return instruction. </param> public void SetOriCodeReturn(byte stackCleanupParams = 0) { if (oriCodeSetting != OriCodeSetting.Return || this.returnParams != stackCleanupParams) { if (stackCleanupParams == 0) { Process.WriteByte(oriCodeAddress, 0xC3); Process.Nop(oriCodeAddress + 1, Length - 1); } else { Process.WriteByte(oriCodeAddress, 0xC2); Process.WriteUShort(oriCodeAddress + 1, (ushort)(4 * stackCleanupParams)); Process.Nop(oriCodeAddress + 3, Length - 3); } oriCodeSetting = OriCodeSetting.Return; this.returnParams = stackCleanupParams; } }