Exemplo n.º 1
0
        public void Run(RemoteHooking.IContext context, string channelName, EntryPointParameters parameter)
        {
            try
            {
                using (var extractArchiveHook = LocalHook.Create(LocalHook.GetProcAddress("mia.lib", "ExtractArchive"),
                                                                 new ExtractArchiveFnPtr(ExtractArchive_Hooked),
                                                                 this))
                {
                    // Don't forget that all hooks will start deactivated.
                    // The following ensures that all threads are intercepted:
                    extractArchiveHook.ThreadACL.SetExclusiveACL(new int[1]);

                    _remoteObject.TriggerInjectionEvent(RemoteHooking.GetCurrentProcessId());
                    _remoteObject.TriggerMessageEvent(parameter.Message);

                    while (true)
                    {
                        Thread.Sleep(TimeSpan.FromMilliseconds(100));
                        _remoteObject.TriggerPingEvent();
                    }
                }
            }
            catch (Exception e)
            {
                // We should notice our host process about this error
                _remoteObject.TriggerExceptionEvent(e);
            }
            finally
            {
                _remoteObject.TriggerExitEvent();
            }
        }