Virustotal 将我的程序的 32 位版本标记为恶意软件
Virustotal flag 32 bit version of my program as malware
我 运行 遇到了一件非常奇怪的事情。我用 C# 编写了一个非常简单的程序,并尝试构建它的 32 位和 64 位版本。 64 位版本工作正常,但每当我尝试构建 32 位版本时,我的防病毒软件都会将其删除。我已将这两个文件上传到 virustotal:
为什么?它的代码完全相同,唯一的区别是我在构建 x64 和 x86 之前切换了它们。
从代码中删除 P/Invokes 后,您可以将项目设置为 AnyCPU。这样您就不需要 x86 和 x64 构建。
我在你的项目中没有看到任何不合适的地方,除了使用以下几行:
[DllImport("psapi.dll")]
static extern int EmptyWorkingSet(IntPtr hwProc);
static void MinimizeFootprint()
{
EmptyWorkingSet(System.Diagnostics.Process.GetCurrentProcess().Handle);
}
...
GC.Collect();
MinimizeFootprint();
考虑到您的小型应用程序,确实不需要手动调用垃圾收集器和调整工作集。 There are known issues with using it.
相反,当你用完画笔后清理它们:
private void DrawResistor(PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush brs;
//Første farve
g.DrawLine(Pens.Black, 130, 35, 130, 109);
g.DrawLine(Pens.Black, 140, 35, 140, 109);
using (brs = new SolidBrush(this.Controls.Find(Farver[0], false)[0].BackColor))
{
g.FillRectangle(brs, 131, 35, 9, 75);
}
//Anden farve
g.DrawLine(Pens.Black, 160, 44, 160, 100);
g.DrawLine(Pens.Black, 170, 44, 170, 100);
using (brs = new SolidBrush(this.Controls.Find(Farver[1], false)[0].BackColor))
{
g.FillRectangle(brs, 161, 44, 9, 56);
}
//Tredje farve
if (comboBox1.SelectedIndex != 0)
{
g.DrawLine(Pens.Black, 190, 44, 190, 100);
g.DrawLine(Pens.Black, 200, 44, 200, 100);
using (brs = new SolidBrush(this.Controls.Find(Farver[2], false)[0].BackColor))
{
g.FillRectangle(brs, 191, 44, 9, 56);
}
}
//Fjerde farve
g.DrawLine(Pens.Black, 220, 44, 220, 100);
g.DrawLine(Pens.Black, 230, 44, 230, 100);
using (brs = new SolidBrush(this.Controls.Find(Farver[3], false)[0].BackColor))
{
g.FillRectangle(brs, 221, 44, 9, 56);
}
//Femte farve
g.DrawLine(Pens.Black, 265, 35, 265, 109);
g.DrawLine(Pens.Black, 280, 35, 280, 109);
using (brs = new SolidBrush(this.Controls.Find(Farver[4], false)[0].BackColor))
{
g.FillRectangle(brs, 266, 35, 14, 75);
}
//Sjette farve
if (comboBox1.SelectedIndex == 2)
{
g.DrawLine(Pens.Black, 293, 35, 293, 109);
g.DrawLine(Pens.Black, 303, 35, 303, 109);
using (brs = new SolidBrush(this.Controls.Find(Farver[5], false)[0].BackColor))
{
g.FillRectangle(brs, 294, 35, 9, 75);
}
}
}
我 运行 遇到了一件非常奇怪的事情。我用 C# 编写了一个非常简单的程序,并尝试构建它的 32 位和 64 位版本。 64 位版本工作正常,但每当我尝试构建 32 位版本时,我的防病毒软件都会将其删除。我已将这两个文件上传到 virustotal:
为什么?它的代码完全相同,唯一的区别是我在构建 x64 和 x86 之前切换了它们。
从代码中删除 P/Invokes 后,您可以将项目设置为 AnyCPU。这样您就不需要 x86 和 x64 构建。
我在你的项目中没有看到任何不合适的地方,除了使用以下几行:
[DllImport("psapi.dll")]
static extern int EmptyWorkingSet(IntPtr hwProc);
static void MinimizeFootprint()
{
EmptyWorkingSet(System.Diagnostics.Process.GetCurrentProcess().Handle);
}
...
GC.Collect();
MinimizeFootprint();
考虑到您的小型应用程序,确实不需要手动调用垃圾收集器和调整工作集。 There are known issues with using it.
相反,当你用完画笔后清理它们:
private void DrawResistor(PaintEventArgs e)
{
Graphics g = e.Graphics;
SolidBrush brs;
//Første farve
g.DrawLine(Pens.Black, 130, 35, 130, 109);
g.DrawLine(Pens.Black, 140, 35, 140, 109);
using (brs = new SolidBrush(this.Controls.Find(Farver[0], false)[0].BackColor))
{
g.FillRectangle(brs, 131, 35, 9, 75);
}
//Anden farve
g.DrawLine(Pens.Black, 160, 44, 160, 100);
g.DrawLine(Pens.Black, 170, 44, 170, 100);
using (brs = new SolidBrush(this.Controls.Find(Farver[1], false)[0].BackColor))
{
g.FillRectangle(brs, 161, 44, 9, 56);
}
//Tredje farve
if (comboBox1.SelectedIndex != 0)
{
g.DrawLine(Pens.Black, 190, 44, 190, 100);
g.DrawLine(Pens.Black, 200, 44, 200, 100);
using (brs = new SolidBrush(this.Controls.Find(Farver[2], false)[0].BackColor))
{
g.FillRectangle(brs, 191, 44, 9, 56);
}
}
//Fjerde farve
g.DrawLine(Pens.Black, 220, 44, 220, 100);
g.DrawLine(Pens.Black, 230, 44, 230, 100);
using (brs = new SolidBrush(this.Controls.Find(Farver[3], false)[0].BackColor))
{
g.FillRectangle(brs, 221, 44, 9, 56);
}
//Femte farve
g.DrawLine(Pens.Black, 265, 35, 265, 109);
g.DrawLine(Pens.Black, 280, 35, 280, 109);
using (brs = new SolidBrush(this.Controls.Find(Farver[4], false)[0].BackColor))
{
g.FillRectangle(brs, 266, 35, 14, 75);
}
//Sjette farve
if (comboBox1.SelectedIndex == 2)
{
g.DrawLine(Pens.Black, 293, 35, 293, 109);
g.DrawLine(Pens.Black, 303, 35, 303, 109);
using (brs = new SolidBrush(this.Controls.Find(Farver[5], false)[0].BackColor))
{
g.FillRectangle(brs, 294, 35, 9, 75);
}
}
}