From 8c8cf073851503d2a7fa27b6237d499fce03d79e Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 2 Jan 2017 15:21:17 +0000 Subject: [PATCH] Add helper menu items to tools menu if rdocself.dll is loaded --- renderdoccmd/renderdoccmd.vcxproj | 1 + renderdocui/Code/Win32PInvoke.cs | 2 ++ renderdocui/Windows/MainWindow.cs | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/renderdoccmd/renderdoccmd.vcxproj b/renderdoccmd/renderdoccmd.vcxproj index 33a016a37..7b7de56af 100644 --- a/renderdoccmd/renderdoccmd.vcxproj +++ b/renderdoccmd/renderdoccmd.vcxproj @@ -22,6 +22,7 @@ {D03DF2F9-513C-4084-BBDD-1DEE8D9250D7} Win32Proj renderdoccmd + renderdoccmd diff --git a/renderdocui/Code/Win32PInvoke.cs b/renderdocui/Code/Win32PInvoke.cs index 2f56f9406..87c5b9146 100644 --- a/renderdocui/Code/Win32PInvoke.cs +++ b/renderdocui/Code/Win32PInvoke.cs @@ -36,6 +36,8 @@ namespace renderdocui.Code { [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)] public static extern IntPtr LoadLibrary(string lpFileName); + [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)] + public static extern IntPtr GetModuleHandle(string lpFileName); [StructLayout(LayoutKind.Sequential)] public struct POINT diff --git a/renderdocui/Windows/MainWindow.cs b/renderdocui/Windows/MainWindow.cs index 31d4180c3..fa1039fd7 100644 --- a/renderdocui/Windows/MainWindow.cs +++ b/renderdocui/Windows/MainWindow.cs @@ -176,6 +176,23 @@ namespace renderdocui.Windows { bool loaded = LoadLayout(0); + if (Win32PInvoke.GetModuleHandle("rdocself.dll") != IntPtr.Zero) + { + ToolStripMenuItem beginSelfCap = new ToolStripMenuItem(); + beginSelfCap.Text = "Start Self-hosted Capture"; + beginSelfCap.Click += new EventHandler((object o, EventArgs a) => { StaticExports.StartSelfHostCapture("rdocself.dll"); }); + + ToolStripMenuItem endSelfCap = new ToolStripMenuItem(); + endSelfCap.Text = "End Self-hosted Capture"; + endSelfCap.Click += new EventHandler((object o, EventArgs a) => { StaticExports.EndSelfHostCapture("rdocself.dll"); }); + + toolsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { + new System.Windows.Forms.ToolStripSeparator(), + beginSelfCap, + endSelfCap, + }); + } + CheckUpdates(); Thread remoteStatusThread = Helpers.NewThread(new ThreadStart(() =>