public override void SetHook(HookInfo info) { if (HookInfos.Count > 0) { throw new InvalidOperationException("JumpHook can not mix with other hook"); } base.SetHook(info); HookAttribute hook = info.GetHookAttribute(); switch (hook.Type) { case HookType.SimpleJumpToRet: int address = (int)info.GetReturnValue(); Logger.Log("jump to address: 0x{0:X}", address); ASMWriter.WriteJump(new JumpStruct(hook.Address, address)); break; case HookType.DirectJumpToHook: int callable = (int)info.GetCallable(); Logger.Log("jump to callable: 0x{0:X}", callable); ASMWriter.WriteJump(new JumpStruct(hook.Address, callable)); break; default: Logger.LogError("found unkwnow jump hook: " + info.Member.Name); break; } }
public override void SetHook(HookInfo info) { if (HookInfos.Count > 0) { throw new InvalidOperationException("WriteBytesHook can not mix with other hook"); } base.SetHook(info); HookAttribute hook = info.GetHookAttribute(); var bytes = info.GetReturnValue() as byte[]; Logger.Log("write bytes: [{0}]", string.Join(", ", bytes)); MemoryHelper.Write(hook.Address, bytes, bytes.Length); }