From a3be164055e770a68d6504ce18cba71e22fd06a0 Mon Sep 17 00:00:00 2001 From: Eviatar Gerzi Date: Fri, 4 Nov 2022 14:26:43 +0200 Subject: [PATCH] Add requirement to run RPCMon as Administrator --- .gitignore | 6 +++ RPCMon/Form1.cs | 24 +++++++++- RPCMon/Properties/AssemblyInfo.cs | 4 +- RPCMon/RPCMon.csproj | 32 +++++++++++++ RPCMon/RPCMon.csproj.user | 13 ++++++ RPCMon/app.manifest | 76 +++++++++++++++++++++++++++++++ 6 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 RPCMon/RPCMon.csproj.user create mode 100644 RPCMon/app.manifest diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7e9dbb --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ + +RPCMon/bin/ + +RPCMon/obj/ + +.vs/ diff --git a/RPCMon/Form1.cs b/RPCMon/Form1.cs index de695af..8a29dc4 100644 --- a/RPCMon/Form1.cs +++ b/RPCMon/Form1.cs @@ -16,6 +16,7 @@ using Newtonsoft.Json; using Microsoft.Diagnostics.Tracing.Parsers.MicrosoftWindowsRPC; using RPCMon.Control; using System.Reflection; +using System.Security.Principal; namespace RPCMon { @@ -38,10 +39,13 @@ namespace RPCMon private ListView m_LastListViewColumnFilter = new ListView(); private ListView m_LastListViewHighlighFilter = new ListView(); int m_CurrentRowIndexRightClick, m_CurrentColumnIndexRightClick; + bool m_IsElevated = false; public Form1() { InitializeComponent(); + configureFormBasedPrivileges(); + this.m_RPCDBPath = getDBFromCurrentFolder(); this.toolStripStatusLabelDBPath.Text = "DB File: " + Path.GetFileName(this.m_RPCDBPath); @@ -84,6 +88,22 @@ namespace RPCMon new object[] { true }); } + private void configureFormBasedPrivileges() + { + bool isElevated; + using (WindowsIdentity identity = WindowsIdentity.GetCurrent()) + { + WindowsPrincipal principal = new WindowsPrincipal(identity); + isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator); + m_IsElevated = isElevated; + if (isElevated) + { + this.Text = "RPCMon - RPC Monitor Based Windows Events (Administrator)"; + } + } + } + + private void checkIdDBGHelpExist() { if (!File.Exists(Engine.DbgHelpFilePath)) @@ -307,6 +327,7 @@ namespace RPCMon private void toolStripButtonStart_Click(object sender, EventArgs e) { + if (!m_IsCaptureButtonPressed) { toolStripButtonStart.Image = global::RPCMon.Properties.Resources.pause_button; @@ -324,7 +345,6 @@ namespace RPCMon m_TraceSession.Dispose(); m_CaptureThread.Abort(); } - } /*private void toolStripButtonStop_Click(object sender, EventArgs e) @@ -845,7 +865,7 @@ namespace RPCMon private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Authors: Eviatar Gerzi (@g3rzi) and Yaniv Yakobovich\nVersion: 1.0\n\nCopyright (c) 2022 CyberArk Software Ltd. All rights reserved", "About"); + MessageBox.Show("Authors: Eviatar Gerzi (@g3rzi) and Yaniv Yakobovich\nVersion: 1.1\n\nCopyright (c) 2022 CyberArk Software Ltd. All rights reserved", "About"); } private void toolStripButtonFind_Click(object sender, EventArgs e) diff --git a/RPCMon/Properties/AssemblyInfo.cs b/RPCMon/Properties/AssemblyInfo.cs index 884a165..ee0587f 100644 --- a/RPCMon/Properties/AssemblyInfo.cs +++ b/RPCMon/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/RPCMon/RPCMon.csproj b/RPCMon/RPCMon.csproj index a54f9b8..e605539 100644 --- a/RPCMon/RPCMon.csproj +++ b/RPCMon/RPCMon.csproj @@ -12,6 +12,21 @@ 512 true true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.1.0.%2a + false + false + true x64 @@ -33,6 +48,10 @@ prompt 4 + + + app.manifest + ..\Packages\Microsoft.Diagnostics.Tracing.TraceEvent.2.0.42\lib\net45\Microsoft.Diagnostics.Tracing.TraceEvent.dll @@ -130,6 +149,7 @@ Resources.resx True + SettingsSingleFileGenerator @@ -181,5 +201,17 @@ + + + False + Microsoft .NET Framework 4.6.1 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/RPCMon/RPCMon.csproj.user b/RPCMon/RPCMon.csproj.user new file mode 100644 index 0000000..7937b01 --- /dev/null +++ b/RPCMon/RPCMon.csproj.user @@ -0,0 +1,13 @@ + + + + publish\ + + + + + + en-US + false + + \ No newline at end of file diff --git a/RPCMon/app.manifest b/RPCMon/app.manifest new file mode 100644 index 0000000..d72e750 --- /dev/null +++ b/RPCMon/app.manifest @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +