public Renderer(IntPtr swapChainPtr, OverlayConfig overlayConfig) { OverlayConfig = overlayConfig; Overlays = new List<IOverlay>(); var swapChain = (SwapChain) swapChainPtr; Device = swapChain.GetDevice<Device>(); Texture2D = swapChain.GetBackBuffer<Texture2D>(0); try { DeviceContext = new DeviceContext(Device); } catch (SharpDXException) { DeviceContext = Device.ImmediateContext; } TargetView = new RenderTargetView(Device, Texture2D); if (DeferredContext) { DeviceContext.Rasterizer.SetViewports(new ViewportF(0, 0, Texture2D.Description.Width, Texture2D.Description.Height, 0, 1)); DeviceContext.OutputMerger.SetTargets(TargetView); } SpriteEngine = new DXSpriteRenderer(Device, DeviceContext); SpriteEngine?.Initialize(); InitializeElementResources(); }
public void Run( RemoteHooking.IContext context, string channelName, OverlayConfig config) { // When not using GAC there can be issues with remoting assemblies resolving correctly // this is a workaround that ensures that the current assembly is correctly associated var currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += (sender, args) => GetType().Assembly.FullName == args.Name ? GetType().Assembly : null; // NOTE: This is running in the target process _interface.Message(MessageType.Information, "Injected into process Id:{0}.", RemoteHooking.GetCurrentProcessId()); _runWait = new ManualResetEvent(false); _runWait.Reset(); try { // Initialise the Hook if (!InitialiseDirectXHook(config)) { return; } // We start a thread here to periodically check if the host is still running // If the host process stops then we will automatically uninstall the hooks StartCheckHostIsAliveThread(); // Wait until signaled for exit either when a Disconnect message from the host // or if the the check is alive has failed to Ping the host. _runWait.WaitOne(); // we need to tell the check host thread to exit (if it hasn't already) StopCheckHostIsAliveThread(); // Dispose of the DXHook so any installed hooks are removed correctly DisposeDirectXHook(); } catch (Exception e) { _interface.Message(MessageType.Error, "An unexpected error occured: {0}", e.ToString()); } finally { try { _interface.Message(MessageType.Information, "Disconnecting from process {0}", RemoteHooking.GetCurrentProcessId()); } catch { } // Remove the client server channel (that allows client event handlers) ChannelServices.UnregisterChannel(_clientServerChannel); // Always sleep long enough for any remaining messages to complete sending Thread.Sleep(100); } }
void CreateDevelopOverlay() { var web = CreateOverlay(OverlayConfig.CreateFromJSON(developOverlay)).GetComponent <Vuplex.WebView.CanvasWebViewPrefab>(); web.InitialUrl = null; web.Initialized += DevelopOverlayInitialized; }
public EntryPoint( RemoteHooking.IContext context, string channelName, OverlayConfig config) { // Get reference to IPC to host application // Note: any methods called or events triggered against _interface will execute in the host process. _interface = RemoteHooking.IpcConnectClient <OverlayInterface>(channelName); // We try to ping immediately, if it fails then injection fails _interface.Ping(); #region Allow client event handlers (bi-directional IPC) // Attempt to create a IpcServerChannel so that any event handlers on the client will function correctly IDictionary properties = new Hashtable(); properties["name"] = channelName; properties["portName"] = channelName + Guid.NewGuid().ToString("N"); // random portName so no conflict with existing channels of channelName var binaryProv = new BinaryServerFormatterSinkProvider(); binaryProv.TypeFilterLevel = TypeFilterLevel.Full; var clientServerChannel = new IpcServerChannel(properties, binaryProv); ChannelServices.RegisterChannel(clientServerChannel, false); #endregion }
GameObject CreateOverlay(OverlayConfig config) { GameObject overlay = Instantiate(prefab, Vector3.zero, Quaternion.identity, null); overlays.Add(overlay); overlay.GetComponent <InitializeRenderTexture>().SetRenderSize(config.resolution.x, config.resolution.y); EasyOpenVROverlayForUnity o = overlay.GetComponent <EasyOpenVROverlayForUnity>(); o.Position = config.position; o.Rotation = config.rotation; o.width = config.width; o.OverlayFriendlyName = config.name; o.OverlayKeyName = config.id; if (config.device == null || config.device == "None") { o.DeviceTracking = false; } else { o.DeviceTracking = true; switch (config.device) { case "HMD": o.changeToHMD(); break; case "Left": o.changeToLeftController(); break; case "Right": o.changeToRightController(); break; default: o.DeviceSerialNumber = config.device; break; } } o.MirrorX = OverlayConfig.MirrorX; o.MirrorY = OverlayConfig.MirrorY; Vuplex.WebView.CanvasWebViewPrefab web = overlay.GetComponent <Vuplex.WebView.CanvasWebViewPrefab>(); if (config.url.StartsWith(".")) { config.url = System.IO.Path.GetFullPath(config.url); } web.InitialUrl = config.url; return(overlay); }
public OverlayWindow() { InitializeComponent(); OverlayConfig config = new OverlayConfig(); mDefaultCursor = new Cursor(config.DefaultCursor); Cursor = mDefaultCursor; TopMost = true; }
/// <summary> /// Prepares capturing in the target process. Note that the process must not already be hooked, and must have a <see cref="Process.MainWindowHandle"/>. /// </summary> /// <param name="process">The process to inject into</param> /// <exception cref="ProcessHasNoWindowHandleException">Thrown if the <paramref name="process"/> does not have a window handle. This could mean that the process does not have a UI, or that the process has not yet finished starting.</exception> /// <exception cref="ProcessAlreadyHookedException">Thrown if the <paramref name="process"/> is already hooked</exception> /// <exception cref="InjectionFailedException">Thrown if the injection failed - see the InnerException for more details.</exception> /// <remarks>The target process will have its main window brought to the foreground after successful injection.</remarks> public OverlayProcess(Process process, OverlayConfig config, OverlayInterface overlayInterface) { // If the process doesn't have a mainwindowhandle yet, skip it (we need to be able to get the hwnd to set foreground etc) if (process.MainWindowHandle == IntPtr.Zero) { throw new ProcessHasNoWindowHandleException(); } // Skip if the process is already hooked (and we want to hook multiple applications) if (HookManager.IsHooked(process.Id)) { throw new ProcessAlreadyHookedException(); } _serverInterface = overlayInterface; //_serverInterface = new OverlayInterface() { ProcessId = process.Id }; // Initialise the IPC server (with our instance of _serverInterface) RemoteHooking.IpcCreateServer( ref _channelName, WellKnownObjectMode.Singleton, _serverInterface); try { var libPath = typeof(OverlayInterface).Assembly.Location; RemoteHooking.Inject( process.Id, InjectionOptions.Default, libPath, libPath, _channelName, config ); } catch (Exception e) { throw new InjectionFailedException(e); } HookManager.AddHookedProcess(process.Id); Process = process; // Ensure the target process is in the foreground, // this prevents an issue where the target app appears to be in // the foreground but does not receive any user inputs. // Note: the first Alt+Tab out of the target application after injection // may still be an issue - switching between windowed and // fullscreen fixes the issue however (see ScreenshotInjection.cs for another option) BringProcessWindowToFront(); }
public void loadJSON() { config = null; menu.DirectoryCheck(); //ファイルがない場合: 初期設定ファイルの生成 if (!File.Exists(jsonPath)) { config = new OverlayConfig(); makeJSON(); } //ファイルの読込を試行 try { //ファイルの内容を一括読み出し string jsonString = File.ReadAllText(jsonPath, new UTF8Encoding(false)); //設定クラスをJSONデコードして生成 config = JsonUtility.FromJson <OverlayConfig>(jsonString); //ファイルのバージョンが古い場合は、デフォルト設定にして警告(nullの可能性も考慮してtry内) if (config.jsonVer != jsonVerMaster) { menu.ShowDialogOKCancel(LanguageManager.config.jsonloaders.OLD_CONFIG_HEAD, "" + jsonPath + LanguageManager.config.jsonloaders.OLD_CONFIG_BODY, 3f, () => { //OK makeJSON(); }, () => { //キャンセル }); config = new OverlayConfig(); } } catch (System.Exception e) { //JSONデコードに失敗した場合 Debug.Log(e.ToString()); config = null; } //デコード失敗した場合は、デフォルト設定にして警告 if (config == null) { config = new OverlayConfig(); menu.ShowDialogOKCancel(LanguageManager.config.jsonloaders.CORRUPT_CONFIG_HEAD, "" + jsonPath + LanguageManager.config.jsonloaders.CORRUPT_CONFIG_BODY, 3f, () => { //OK makeJSON(); }, () => { //キャンセル }); } }
public OverlayReference Attach(RenderFragment overlayContent, OverlayConfig overlayConfig) { _sequenceNumber++; var overlayReference = new OverlayReference(_sequenceNumber); _overlayReferences.Add(overlayReference); overlayConfig.OverlayRef = overlayReference.OverlayReferenceId; OnAttach?.Invoke(overlayContent, overlayConfig); return(overlayReference); }
private void btn_saveConfig_Click(object sender, RoutedEventArgs e) { var config = new OverlayConfig() { ProcessFilePath = attachedProcessFilePath, CrosshairColorIndex = cmb_color.SelectedIndex, CrosshairFileLocation = crosshairOverlayWindow.CrosshairImagePath, CrosshairOpacity = sldr_Opacity.Value, CrosshairScale = crosshairOverlayWindow.CrosshairScale, OffsetX = OffsetX, OffsetY = OffsetY }; configSaver.SaveConfig(config); MessageBox.Show("Config saved successfully"); }
private OverlayReference Open <TContentData>(Type componentType, DialogConfig dialogConfig, ContentData contentData) { if (!typeof(ComponentBase).IsAssignableFrom(componentType)) { throw new ArgumentException($"{componentType.FullName} must be a Blazor Component"); } var globalPositionStrategy = new GlobalPositionStrategyBuilder(); globalPositionStrategy.CenterVertically(""); globalPositionStrategy.CenterHorizontally(""); var overlayConfig = new OverlayConfig() { HasBackdrop = dialogConfig.HasBackdrop, HasTransparentBackdrop = dialogConfig.HasTransparentBackdrop, Width = dialogConfig.Width, Height = dialogConfig.Height, GlobalPositionStrategy = globalPositionStrategy }; var userContent = new RenderFragment(x => { x.OpenComponent(0, componentType); x.AddAttribute(1, "ContentData", contentData); x.CloseComponent(); }); var dialog = new RenderFragment(x => { x.OpenComponent(0, typeof(DnetDialog)); x.AddAttribute(1, "Title", dialogConfig.Title); x.AddAttribute(2, "DialogClass", dialogConfig.DialogClass); x.AddAttribute(3, "ContentChild", userContent); x.CloseComponent(); }); var overlayReference = _overlayService.Attach(dialog, overlayConfig); return(overlayReference); }
public void Reload() { Debug.Log("Start Reloading"); foreach (var o in overlays) { Destroy(o); } overlays.Clear(); FilePathUI.text = configFilePath; string config = System.IO.File.ReadAllText(configFilePath); foreach (var d in OverlayConfig.CreateArrayFromJSON(config)) { CreateOverlay(d); } CreateDevelopOverlay(); Debug.Log("Reloaded"); }
private void ConfigOverlay(OverlayConfig cfg) { Overlay.transform.position = cfg.PositionP; Overlay.transform.rotation = Quaternion.Euler(cfg.RotationP); }
private void OnOverlayCreate(OverlayConfig c) { OverlayTabAdd?.Invoke(this, new OverlayTabAddEventArgs(c)); }
public OverlayTabAddEventArgs(OverlayConfig c) { Config = c; }
private bool InitialiseDirectXHook(OverlayConfig config) { var version = config.Direct3DVersion; var loadedVersions = new List <Direct3DVersion>(); var isX64Process = RemoteHooking.IsX64Process(RemoteHooking.GetCurrentProcessId()); _interface.Message(MessageType.Information, "Remote process is a {0}-bit process.", isX64Process ? "64" : "32"); try { if (version == Direct3DVersion.Unknown) { // Attempt to determine the correct version based on loaded module. // In most cases this will work fine, however it is perfectly ok for an application to use a D3D10 device along with D3D11 devices // so the version might matched might not be the one you want to use var d3D9Loaded = IntPtr.Zero; var d3D10Loaded = IntPtr.Zero; var d3D101Loaded = IntPtr.Zero; var d3D11Loaded = IntPtr.Zero; var d3D111Loaded = IntPtr.Zero; var delayTime = 100; var retryCount = 0; while (d3D9Loaded == IntPtr.Zero && d3D10Loaded == IntPtr.Zero && d3D101Loaded == IntPtr.Zero && d3D11Loaded == IntPtr.Zero && d3D111Loaded == IntPtr.Zero) { retryCount++; d3D9Loaded = NativeMethods.GetModuleHandle("d3d9.dll"); d3D10Loaded = NativeMethods.GetModuleHandle("d3d10.dll"); d3D101Loaded = NativeMethods.GetModuleHandle("d3d10_1.dll"); d3D11Loaded = NativeMethods.GetModuleHandle("d3d11.dll"); d3D111Loaded = NativeMethods.GetModuleHandle("d3d11_1.dll"); Thread.Sleep(delayTime); if (retryCount * delayTime > 5000) { _interface.Message(MessageType.Error, "Unsupported Direct3D version, or Direct3D DLL not loaded within 5 seconds."); return(false); } } version = Direct3DVersion.Direct3D9; if (d3D9Loaded != IntPtr.Zero) { _interface.Message(MessageType.Debug, "Autodetect found Direct3D 9"); version = Direct3DVersion.Direct3D9; loadedVersions.Add(version); } } else { // If not autodetect, assume specified version is loaded loadedVersions.Add(version); } foreach (var dxVersion in loadedVersions) { version = dxVersion; switch (version) { case Direct3DVersion.Direct3D9: _directXHook = new DxHookD3D9(_interface); break; default: _interface.Message(MessageType.Error, "Unsupported Direct3D version: {0}", version); return(false); } _directXHook.Config = config; _directXHook.Hook(); _directXHooks.Add(_directXHook); } return(true); } catch (Exception e) { // Notify the host/server application about this error _interface.Message(MessageType.Error, "Error in InitialiseHook: {0}", e.ToString()); return(false); } }