internal void SetPluginProxy(PluginProxy proxy) { foreach (var p in proxy.Plugins) { plugins.Add(new PluginItemViewModel(p)); } }
private void StackScanner(ConcurrentQueue <string> queue) { while (true) { queue.TryDequeue(out var changedObjectPath); if (string.IsNullOrEmpty(changedObjectPath)) { continue; } PluginResult scanResult = PluginProxy.Instance(_config).Scan(changedObjectPath, PluginType.File); if (scanResult.RiskRate != ThreatRiskRates.NoRisk) { bool?sendCommandResult = _pipeServer?.SendCommandToUI(new BeSafePipeCommand { CommandId = Guid.NewGuid(), Command = PipeCommands.PluginScanResult, PluginScanResult = scanResult }); // Log threat ThreatLog.Log(scanResult); } Thread.Sleep(500); } }
private void StackScanner(ConcurrentQueue <ChangedValueInfo> queue) { while (true) { queue.TryDequeue(out var valueInfo); if (valueInfo == null) { continue; } PluginResult scanResult = PluginProxy.Instance(_config).Scan(valueInfo, PluginType.Registry); if (scanResult.RiskRate != ThreatRiskRates.NoRisk) { bool?sendCommandResult = _pipeServer?.SendCommandToUI(new BeSafePipeCommand { CommandId = Guid.NewGuid(), Command = PipeCommands.PluginScanResult, PluginScanResult = scanResult }); // Log threat ThreatLog.Log(scanResult); } Thread.Sleep(500); } }
public void InitPlugin(string pluginPath) { if (PluginProxy != null) { throw new Exception("Attempt to load plugin twice"); } PluginProxy = new PluginProxy(pluginPath); }
public override void OnRegister() { base.OnRegister(); _pluginProxy = (PluginProxy) Facade.RetrieveProxy(PluginProxy.NAME); List<IPlugin> Plugins = _pluginProxy.GetPluginList(); for(int i = 0; i < Plugins.Count; i++){ View.AddPlugin(i, Plugins[i]); } }
private ThreatRiskRates OnFileAccessRequestEvent(string filePath) { PluginResult scanResult = PluginProxy.Instance(_config).Scan(filePath, PluginType.File); if (scanResult.RiskRate != ThreatRiskRates.NoRisk) { bool?sendCommandResult = _pipeServer?.SendCommandToUI(new BeSafePipeCommand { CommandId = Guid.NewGuid(), Command = PipeCommands.PluginScanResult, PluginScanResult = scanResult }); // Log threat ThreatLog.Log(scanResult); } return(scanResult.RiskRate); }
static CSharpPluginLoader() { Evidence evidence = new Evidence(Assembly.GetExecutingAssembly().Evidence); AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation; pluginAppDomain = AppDomain.CreateDomain("BukkitNETPlugins", evidence, setup); _proxy = (PluginProxy)pluginAppDomain.CreateInstanceAndUnwrap(proxyType.Assembly.FullName, proxyType.FullName); AppDomain.CurrentDomain.AssemblyResolve += (s, e) => { string asmBase = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "plugins"); Assembly assm = null; string strTempAssmbPath = string.Empty; Assembly objExecutingAssemblies = Assembly.GetExecutingAssembly(); AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies(); AssemblyName myAssemblyName = Array.Find <AssemblyName>(arrReferencedAssmbNames, a => a.Name == e.Name); if (myAssemblyName != null) { assm = Assembly.LoadFrom(myAssemblyName.CodeBase); } else { strTempAssmbPath = Path.Combine(asmBase, e.Name.Substring(0, e.Name.IndexOf(",")) + ".dll"); if (!string.IsNullOrEmpty(strTempAssmbPath)) { if (File.Exists(strTempAssmbPath)) { assm = Assembly.LoadFrom(strTempAssmbPath); } } } return(assm); }; }
public string MapDrive(string virtualPath) { if (string.IsNullOrEmpty(virtualPath)) { throw new ArgumentNullException(nameof(virtualPath)); } try { string beSafeDriveLetter = CheckPathAlreadyMapped(virtualPath); if (!string.IsNullOrEmpty(beSafeDriveLetter)) { return(beSafeDriveLetter); } string unusedDriveLetter = FirstUnusedDriveLetter(); string normalizedDriveLetter = NormalizeDriveLetter(unusedDriveLetter); Task.Run(() => { BeSafeConfig config = ConfigLoader.Instance().LoadConfig(); IPluginProxy pluginRegulator = new PluginProxy(config); _virtualDriveImpl = new BeSafeFileSystemImpl(virtualPath, pluginRegulator); _virtualDriveImpl.FileAccessRequest += FileAccessRequestEvent; _virtualDriveImpl.Mount(normalizedDriveLetter, DokanOptions.FixedDrive, NumberOfThradsToManageFileSystem); }); return(normalizedDriveLetter); } catch (Exception ex) { ex.Log(ExceptionType.SecureVolume, "Can not mount virtual drive"); return(null); } }
static IntPtr getName() { return(PluginProxy.getName()); }
static uint messageProc(uint Message, IntPtr wParam, IntPtr lParam) { return(PluginProxy.messageProc(Message, wParam, lParam)); }
static IntPtr getFuncsArray(ref int nbF) { return(PluginProxy.getFuncsArray(ref nbF)); }
static void setInfo(NppData notepadPlusData) { PluginProxy.setInfo(notepadPlusData); }
static bool isUnicode() { return(PluginProxy.isUnicode()); }
static UnmanagedExports() { // Debug.Assert(false); PluginProxy.Init(); }
static void beNotified(IntPtr notifyCode) { PluginProxy.beNotified(notifyCode); }