public UnmanagedEvent(EventInfo ev, uint tohook, ushort stack_cleanup_size, bool isVtblEntry, bool early) { parinfo = ev.EventHandlerType.GetMethods()[0].GetParameters(); m_Hook = LocalHook.Hook(tohook, stack_cleanup_size, isVtblEntry); if (early) { m_Hook.onCall += new LocalHook.OnCallDelegate(m_Hook_Call); } else { m_Hook.afterCall += new LocalHook.OnCallDelegate(m_Hook_Call); } }
//only one instance is ever created; when requesting a reference (proxy) //through remoting from the user app public Client() { m_Client = this;//keep us alive /* * * //for debugging purposes, this object is on the client app (injected code) * //the VS debugger has no access to it... * //...so a console is our only source of debugging info (or attaching IDA to the client would work too ofc) * * Imports.AllocConsole(); * */ //create IClient proxy //this is what we will return to the user app //the UnmanagedObject has all calls intercepted on a proxy //which allows us to forward calls to unmanaged functions (actual client functions) m_ActualClient = (IClient)UnmanagedObject.Create(typeof(IClient), IntPtr.Zero); drop_msg_message = Imports.RegisterWindowMessage("drop_msg_message");//dummy message.. changing an msg.message to this will make sure the client doesn't handle it //callibrations: try { UOCallibration.Callibrate(ProcessHandler.CurrentProcess); } catch (Exception e) { m_CallibrationException = e; } m_PacketInfo = new UnmanagedBuffer((IntPtr)UOCallibration.Callibrations[(uint)UOCallibration.CallibratedFeatures.pPacketInfo]); m_Hooks.Add(LocalHook.Hook((uint)UOCallibration.Callibrations[(uint)UOCallibration.CallibratedFeatures.GeneralPurposeHookAddress], 0, false)); m_Hooks[0].onCall += new LocalHook.OnCallDelegate(Client_onTick); }