mirror of https://github.com/quasar/Quasar.git
Merge pull request #137 from MaxXor/revert-136-CpuRamUsage
Revert "CPU/RAM usage of each process"
This commit is contained in:
commit
8122b76c02
|
@ -292,10 +292,6 @@ namespace xClient.Core.Commands
|
||||||
string[] processes = new string[pList.Length];
|
string[] processes = new string[pList.Length];
|
||||||
int[] ids = new int[pList.Length];
|
int[] ids = new int[pList.Length];
|
||||||
string[] titles = new string[pList.Length];
|
string[] titles = new string[pList.Length];
|
||||||
decimal[] cpuUsage = new decimal[pList.Length];
|
|
||||||
long[] memoryUsage = new long[pList.Length];
|
|
||||||
|
|
||||||
decimal TotalCpuUsage = GetTotalCpuUsage();
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (Process p in pList)
|
foreach (Process p in pList)
|
||||||
|
@ -303,77 +299,12 @@ namespace xClient.Core.Commands
|
||||||
processes[i] = p.ProcessName + ".exe";
|
processes[i] = p.ProcessName + ".exe";
|
||||||
ids[i] = p.Id;
|
ids[i] = p.Id;
|
||||||
titles[i] = p.MainWindowTitle;
|
titles[i] = p.MainWindowTitle;
|
||||||
cpuUsage[i] = ((GetCpuUsage(p) / TotalCpuUsage) * 100);
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
new Packets.ClientPackets.GetProcessesResponse(processes, ids, titles).Execute(client);
|
new Packets.ClientPackets.GetProcessesResponse(processes, ids, titles).Execute(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static decimal GetTotalCpuUsage()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PerformanceCounter CpuCounter = new PerformanceCounter()
|
|
||||||
{
|
|
||||||
CategoryName = "Processor",
|
|
||||||
CounterName = "% Processor Time",
|
|
||||||
InstanceName = "_Total"
|
|
||||||
};
|
|
||||||
|
|
||||||
CpuCounter.NextValue();
|
|
||||||
Thread.Sleep(200);
|
|
||||||
|
|
||||||
return (decimal)CpuCounter.NextValue();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return (decimal)100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static decimal GetCpuUsage(Process proc)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PerformanceCounter CpuCounter = new PerformanceCounter()
|
|
||||||
{
|
|
||||||
CategoryName = "Processor",
|
|
||||||
CounterName = "% Processor Time",
|
|
||||||
InstanceName = proc.ProcessName
|
|
||||||
};
|
|
||||||
|
|
||||||
CpuCounter.NextValue();
|
|
||||||
|
|
||||||
return (decimal)CpuCounter.NextValue();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return (decimal)0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long GetMemoryUsage(Process proc)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PerformanceCounter CpuCounter = new PerformanceCounter()
|
|
||||||
{
|
|
||||||
CategoryName = "Memory",
|
|
||||||
CounterName = "Available MBytes",
|
|
||||||
InstanceName = proc.ProcessName
|
|
||||||
};
|
|
||||||
|
|
||||||
CpuCounter.NextValue();
|
|
||||||
|
|
||||||
return (long)CpuCounter.NextValue();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return (long)0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HandleKillProcess(Packets.ServerPackets.KillProcess command, Client client)
|
public static void HandleKillProcess(Packets.ServerPackets.KillProcess command, Client client)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -14,12 +14,6 @@ namespace xClient.Core.Packets.ClientPackets
|
||||||
[ProtoMember(3)]
|
[ProtoMember(3)]
|
||||||
public string[] Titles { get; set; }
|
public string[] Titles { get; set; }
|
||||||
|
|
||||||
[ProtoMember(4)]
|
|
||||||
public decimal[] CpuUsage { get; set; }
|
|
||||||
|
|
||||||
[ProtoMember(5)]
|
|
||||||
public long[] MemoryUsage { get; set; }
|
|
||||||
|
|
||||||
public GetProcessesResponse()
|
public GetProcessesResponse()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,8 +207,7 @@ namespace xServer.Core.Commands
|
||||||
{
|
{
|
||||||
ListViewItem lvi =
|
ListViewItem lvi =
|
||||||
new ListViewItem(new string[]
|
new ListViewItem(new string[]
|
||||||
{packet.Processes[i], packet.IDs[i].ToString(), packet.Titles[i],
|
{packet.Processes[i], packet.IDs[i].ToString(), packet.Titles[i]});
|
||||||
string.Format("{0:0%}", packet.CpuUsage[i]), string.Format("{0:0%}", packet.MemoryUsage[i])});
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.Value.FrmTm.Invoke(
|
client.Value.FrmTm.Invoke(
|
||||||
|
|
|
@ -14,12 +14,6 @@ namespace xServer.Core.Packets.ClientPackets
|
||||||
[ProtoMember(3)]
|
[ProtoMember(3)]
|
||||||
public string[] Titles { get; set; }
|
public string[] Titles { get; set; }
|
||||||
|
|
||||||
[ProtoMember(4)]
|
|
||||||
public decimal[] CpuUsage { get; set; }
|
|
||||||
|
|
||||||
[ProtoMember(5)]
|
|
||||||
public long[] MemoryUsage { get; set; }
|
|
||||||
|
|
||||||
public GetProcessesResponse()
|
public GetProcessesResponse()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,12 @@ namespace xServer.Forms
|
||||||
this.ctxtMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
this.ctxtMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
this.ctxtKillProcess = new System.Windows.Forms.ToolStripMenuItem();
|
this.ctxtKillProcess = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ctxtStartProcess = new System.Windows.Forms.ToolStripMenuItem();
|
this.ctxtStartProcess = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ctxtLine = new System.Windows.Forms.ToolStripSeparator();
|
|
||||||
this.ctxtRefresh = new System.Windows.Forms.ToolStripMenuItem();
|
this.ctxtRefresh = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.lstTasks = new xServer.Controls.ListViewEx();
|
this.lstTasks = new ListViewEx();
|
||||||
this.hProcessname = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.hProcessname = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.hPID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.hPID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.hTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.hTitle = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.hCpu = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.ctxtLine = new System.Windows.Forms.ToolStripSeparator();
|
||||||
this.hRam = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
|
||||||
this.ctxtMenu.SuspendLayout();
|
this.ctxtMenu.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
@ -54,13 +52,13 @@ namespace xServer.Forms
|
||||||
this.ctxtLine,
|
this.ctxtLine,
|
||||||
this.ctxtRefresh});
|
this.ctxtRefresh});
|
||||||
this.ctxtMenu.Name = "ctxtMenu";
|
this.ctxtMenu.Name = "ctxtMenu";
|
||||||
this.ctxtMenu.Size = new System.Drawing.Size(142, 76);
|
this.ctxtMenu.Size = new System.Drawing.Size(153, 98);
|
||||||
//
|
//
|
||||||
// ctxtKillProcess
|
// ctxtKillProcess
|
||||||
//
|
//
|
||||||
this.ctxtKillProcess.Image = global::xServer.Properties.Resources.cancel;
|
this.ctxtKillProcess.Image = global::xServer.Properties.Resources.cancel;
|
||||||
this.ctxtKillProcess.Name = "ctxtKillProcess";
|
this.ctxtKillProcess.Name = "ctxtKillProcess";
|
||||||
this.ctxtKillProcess.Size = new System.Drawing.Size(141, 22);
|
this.ctxtKillProcess.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ctxtKillProcess.Text = "Kill Process";
|
this.ctxtKillProcess.Text = "Kill Process";
|
||||||
this.ctxtKillProcess.Click += new System.EventHandler(this.ctxtKillProcess_Click);
|
this.ctxtKillProcess.Click += new System.EventHandler(this.ctxtKillProcess_Click);
|
||||||
//
|
//
|
||||||
|
@ -68,20 +66,15 @@ namespace xServer.Forms
|
||||||
//
|
//
|
||||||
this.ctxtStartProcess.Image = global::xServer.Properties.Resources.run;
|
this.ctxtStartProcess.Image = global::xServer.Properties.Resources.run;
|
||||||
this.ctxtStartProcess.Name = "ctxtStartProcess";
|
this.ctxtStartProcess.Name = "ctxtStartProcess";
|
||||||
this.ctxtStartProcess.Size = new System.Drawing.Size(141, 22);
|
this.ctxtStartProcess.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ctxtStartProcess.Text = "Start Process";
|
this.ctxtStartProcess.Text = "Start Process";
|
||||||
this.ctxtStartProcess.Click += new System.EventHandler(this.ctxtStartProcess_Click);
|
this.ctxtStartProcess.Click += new System.EventHandler(this.ctxtStartProcess_Click);
|
||||||
//
|
//
|
||||||
// ctxtLine
|
|
||||||
//
|
|
||||||
this.ctxtLine.Name = "ctxtLine";
|
|
||||||
this.ctxtLine.Size = new System.Drawing.Size(138, 6);
|
|
||||||
//
|
|
||||||
// ctxtRefresh
|
// ctxtRefresh
|
||||||
//
|
//
|
||||||
this.ctxtRefresh.Image = global::xServer.Properties.Resources.refresh;
|
this.ctxtRefresh.Image = global::xServer.Properties.Resources.refresh;
|
||||||
this.ctxtRefresh.Name = "ctxtRefresh";
|
this.ctxtRefresh.Name = "ctxtRefresh";
|
||||||
this.ctxtRefresh.Size = new System.Drawing.Size(141, 22);
|
this.ctxtRefresh.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ctxtRefresh.Text = "Refresh";
|
this.ctxtRefresh.Text = "Refresh";
|
||||||
this.ctxtRefresh.Click += new System.EventHandler(this.ctxtRefresh_Click);
|
this.ctxtRefresh.Click += new System.EventHandler(this.ctxtRefresh_Click);
|
||||||
//
|
//
|
||||||
|
@ -90,16 +83,14 @@ namespace xServer.Forms
|
||||||
this.lstTasks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
this.lstTasks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||||
this.hProcessname,
|
this.hProcessname,
|
||||||
this.hPID,
|
this.hPID,
|
||||||
this.hTitle,
|
this.hTitle});
|
||||||
this.hCpu,
|
|
||||||
this.hRam});
|
|
||||||
this.lstTasks.ContextMenuStrip = this.ctxtMenu;
|
this.lstTasks.ContextMenuStrip = this.ctxtMenu;
|
||||||
this.lstTasks.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.lstTasks.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.lstTasks.FullRowSelect = true;
|
this.lstTasks.FullRowSelect = true;
|
||||||
this.lstTasks.GridLines = true;
|
this.lstTasks.GridLines = true;
|
||||||
this.lstTasks.Location = new System.Drawing.Point(0, 0);
|
this.lstTasks.Location = new System.Drawing.Point(0, 0);
|
||||||
this.lstTasks.Name = "lstTasks";
|
this.lstTasks.Name = "lstTasks";
|
||||||
this.lstTasks.Size = new System.Drawing.Size(442, 411);
|
this.lstTasks.Size = new System.Drawing.Size(335, 411);
|
||||||
this.lstTasks.TabIndex = 1;
|
this.lstTasks.TabIndex = 1;
|
||||||
this.lstTasks.UseCompatibleStateImageBehavior = false;
|
this.lstTasks.UseCompatibleStateImageBehavior = false;
|
||||||
this.lstTasks.View = System.Windows.Forms.View.Details;
|
this.lstTasks.View = System.Windows.Forms.View.Details;
|
||||||
|
@ -119,25 +110,22 @@ namespace xServer.Forms
|
||||||
this.hTitle.Text = "Title";
|
this.hTitle.Text = "Title";
|
||||||
this.hTitle.Width = 115;
|
this.hTitle.Width = 115;
|
||||||
//
|
//
|
||||||
// hCpu
|
// ctxtLine
|
||||||
//
|
//
|
||||||
this.hCpu.Text = "CPU";
|
this.ctxtLine.Name = "ctxtLine";
|
||||||
|
this.ctxtLine.Size = new System.Drawing.Size(149, 6);
|
||||||
//
|
//
|
||||||
// hRam
|
// frmTaskManager
|
||||||
//
|
|
||||||
this.hRam.Text = "Memory";
|
|
||||||
//
|
|
||||||
// FrmTaskManager
|
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(442, 411);
|
this.ClientSize = new System.Drawing.Size(335, 411);
|
||||||
this.Controls.Add(this.lstTasks);
|
this.Controls.Add(this.lstTasks);
|
||||||
this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.MinimumSize = new System.Drawing.Size(458, 449);
|
this.MinimumSize = new System.Drawing.Size(351, 449);
|
||||||
this.Name = "FrmTaskManager";
|
this.Name = "frmTaskManager";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "xRAT 2.0 - Task Manager []";
|
this.Text = "xRAT 2.0 - Task Manager []";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmTaskManager_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmTaskManager_FormClosing);
|
||||||
|
@ -158,7 +146,5 @@ namespace xServer.Forms
|
||||||
private System.Windows.Forms.ColumnHeader hPID;
|
private System.Windows.Forms.ColumnHeader hPID;
|
||||||
private System.Windows.Forms.ColumnHeader hTitle;
|
private System.Windows.Forms.ColumnHeader hTitle;
|
||||||
private System.Windows.Forms.ToolStripSeparator ctxtLine;
|
private System.Windows.Forms.ToolStripSeparator ctxtLine;
|
||||||
private System.Windows.Forms.ColumnHeader hCpu;
|
|
||||||
private System.Windows.Forms.ColumnHeader hRam;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue