public bool UnHook() { if (Status == EHookStatus.Inactive) { return(false); } Status = EHookStatus.Inactive; if (_hookIsLiveTimer != null) { _hookIsLiveTimer.Dispose(); _hookIsLiveTimer = null; } _unhookWaitEvent.WaitOne(1000); if (_ipcChannel != null) { ChannelServices.UnregisterChannel(_ipcChannel); _ipcChannel.StopListening(null); _ipcChannel = null; } Thread.Sleep(100); SetDefaults(); return(true); }
public void Form1_FormClosing(object sender, FormClosingEventArgs e) { config["X"] = numResX.Value.ToString(); config["Y"] = numResY.Value.ToString(); config["crosshair"] = cobCHT.SelectedIndex.ToString(); config["drawDot"] = checkUseDot.Checked.ToString(); config["game"] = targetproc; config["customimage"] = customImage; config["autoinject"] = checkAutoInject.Checked.ToString(); config["autoreinject"] = checkAutoReInject.Checked.ToString(); WriteFile(config, "config.ini"); try { int cnt = 0; conMain.closing = true; if (conServer != null) { lblInfo.Text = "Waiting for target to close (200ms)"; while (conMain.closing && cnt < 200) { System.Threading.Thread.Sleep(1); cnt++; Application.DoEvents(); } conServer.StopListening(null); } } catch { } }
public static void UnloadChannel() { if (_channel == null) { return; } try { // cleanup library... _channel.StopListening(null); _channel = null; LightProcessMonitor.Stop(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); } catch (Exception ex) { ExceptionLogger.LogExceptionToFile(ex); AppMessenger.Messenger.NotifyColleagues("AddLog", new Log { Text = string.Format("خطا:{0}", ex) }); } }
private static void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e) { switch (e.Mode) { case Microsoft.Win32.PowerModes.Suspend: //IPC停止 if (_serverChannel != null) { AppObject.Logger.Warn("IPC停止"); _serverChannel.StopListening(null); _serverChannel = null; System.GC.Collect(); } break; case Microsoft.Win32.PowerModes.Resume: //IPC再開 if (_serverChannel == null) { AppObject.Logger.Warn("IPC再開"); RunIPCServer(); } break; } }
public static void Unregister(Type objectType, string label = null, bool ignoreCase = false) { string objectUri = GetObjectUri(objectType, label, ignoreCase); try { lock (SyncRoot) { IChannel channel = ChannelServices.GetChannel(objectUri); if (channel != null) { Type remotingConfigHandlerType = Type.GetType("System.Runtime.Remoting.RemotingConfigHandler, mscorlib"); FieldInfo remotingConfigHandlerFieldInfoInfo = remotingConfigHandlerType.GetField("Info", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); Type identityHolderType = Type.GetType("System.Runtime.Remoting.IdentityHolder, mscorlib"); MethodInfo identityHolderMethodInfoRemoveIdentity = identityHolderType.GetMethod("RemoveIdentity", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(string) }, null); object obj = remotingConfigHandlerFieldInfoInfo.GetValue(null); FieldInfo fieldInfo = obj.GetType().GetField("_wellKnownExportInfo", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); obj = fieldInfo.GetValue(obj); Hashtable registeredTypes = (Hashtable)obj; try { identityHolderMethodInfoRemoveIdentity.Invoke(null, new object[] { objectUri }); registeredTypes.Remove(objectUri.ToLowerInvariant()); } catch { } IpcChannel ipcChannel = channel as IpcChannel; if (ipcChannel != null) { ipcChannel.StopListening(null); } IpcServerChannel ipcServerChannel = channel as IpcServerChannel; if (ipcServerChannel != null) { ipcServerChannel.StopListening(null); } ChannelServices.UnregisterChannel(channel); } } } catch (RemotingException) { } catch (Exception e) { InternalLogger.Log(e); throw; } }
public static void StopInjection() { if (_ipcServer != null) { _ipcServer.StopListening(null); _ipcServer = null; } }
public override void Stop() { _stopped = true; if (_screenshotServer != null) { _screenshotServer.StopListening(null); _screenshotServer = null; } _channelName = null; }
public static void StopInjection() { if (_ipcServer == null) { return; } _ipcServer.StopListening(null); _ipcServer = null; }
/// <summary> /// Disposes of the object. /// </summary> /// <remarks> /// This shuts down any open IPC channels. /// </remarks> public void Dispose() { if (m_schMessagerChannel == null) { return; } m_schMessagerChannel.StopListening(null); ChannelServices.UnregisterChannel(m_schMessagerChannel); m_schMessagerChannel = null; RemotingServices.Disconnect(this); }
private void Dispose(bool disposing) { if (!isDisposed) { isDisposed = true; if (disposing) { _server.StopListening(null); } } }
/// <summary>Stops the IPC server for the Integration Test service.</summary> private void StopServiceCallback(object sender, EventArgs e) { if (_stopServiceMenuCmd.Enabled) { _serviceChannel?.StopListening(null); _marshalledService = null; _serviceChannel = null; _service = null; SwapAvailableCommands(_stopServiceMenuCmd, _startServiceMenuCmd); } }
public void OnExecute(Object InParam) { String[] args = (String[])InParam; try { String ChannelName = args[0]; Mutex TermMutex = Mutex.OpenExisting("Global\\Mutex_" + ChannelName); WellKnownSidType SidType = WellKnownSidType.BuiltinAdministratorsSid; if (!RemoteHooking.IsAdministrator) { SidType = WellKnownSidType.WorldSid; } IpcServerChannel Channel = RemoteHooking.IpcCreateServer <HelperServiceInterface>( ref ChannelName, WellKnownObjectMode.SingleCall, SidType); // signal that service is listening EventWaitHandle Listening = EventWaitHandle.OpenExisting("Global\\Event_" + ChannelName); Listening.Set(); try { TermMutex.WaitOne(); } catch { } // cleanup library... Channel.StopListening(null); Channel = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); } catch (Exception e) { LogError(e.ToString()); } finally { Stop(); } }
/// <summary>Stops the IPC server for the Integration Test service.</summary> private void StopServiceCallback(object sender, EventArgs e) { if (_stopMenuCmd.Enabled) { AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomainAssemblyResolve; if (_serviceChannel != null) { _serviceChannel.StopListening(null); _serviceChannel = null; } _marshalledService = null; _service = null; SwapAvailableCommands(_stopMenuCmd, _startMenuCmd); } }
public bool StopIpcTasks() { if (IpcCh != null) { try { RemotingServices.Disconnect(ShareIpcObject); IpcCh.StopListening(null); ChannelServices.UnregisterChannel(IpcCh); } catch (Exception) { //MessageBox.Show(e.Message, "IPC error2"); } } return(true); }
private void StopServiceCallback(object sender, EventArgs e) { if (_stopMenuCmd.Enabled) { AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomainAssemblyResolve; if (_serviceChannel != null) { _serviceChannel.StopListening(null); _serviceChannel = null; } _marshalledService = null; _service = null; var componentModel = ServiceProvider.GetService <SComponentModel, IComponentModel>(); var asyncCompletionTracker = componentModel.GetService <AsyncCompletionTracker>(); asyncCompletionTracker.StopListening(); SwapAvailableCommands(_stopMenuCmd, _startMenuCmd); } }
public static void Main(string[] args) { Options options; try { options = Options.Parse(args); } catch (Exception e) { MessageBox.Show(e.Message, "Error in command line - disfr"); return; } if (!options.SingleInstance) { var app = new App(); app.Run(); } else { var ipc_port = CreateUniquePort(typeof(App).Assembly); var uri = "Run"; // If two or more process started executing this program at some critical timing, // or an existing App (running as IPC server) is terminating when a new process tried to start, // the IPC channel connection may fail. // We need to detect the case and try again, // but don't retry too much, since the failure may be by other reason (e.g., system resource exhaust.) for (int i = 0; i < 10; i++) { try { // Try to be an IPC server. var server_channel = new IpcServerChannel(null, ipc_port); try { ChannelServices.RegisterChannel(server_channel, true); try { RemotingConfiguration.RegisterWellKnownServiceType(typeof(SingleInstance), uri, WellKnownObjectMode.Singleton); // We've got a server-side IPC channel. Run as a server. try { var app = new App(); app.Exit += (s, e) => server_channel.StopListening(null); app.Run(); } catch (Exception) { // The program may got an exception and terminates, due to a bug. // We SHOULD NOT retry IPC connection in the case. Just terminate. } return; } finally { ChannelServices.UnregisterChannel(server_channel); } } finally { server_channel.StopListening(null); } } catch (Exception) { } // When we got here, it is very likely that an IPC server // (another disfr process with UI) is already running. Thread.Sleep(50); try { // Try to be an IPC client. var client_channel = new IpcClientChannel((string)null, null); ChannelServices.RegisterChannel(client_channel, true); try { var instance = Activator.GetObject(typeof(SingleInstance), "ipc://" + ipc_port + "/" + uri) as SingleInstance; if (instance?.Run(args) == true) { return; } } finally { ChannelServices.UnregisterChannel(client_channel); } } catch (Exception) { } // When we got here, it is likely that an IPC server was running but terminated. Thread.Sleep(50); } MessageBox.Show("Appliation failed: Couldn't establish remoting.", "Error - disfr"); } }
public void Dispose() { _channel.StopListening(null); ChannelServices.UnregisterChannel(_channel); GC.SuppressFinalize(this); }