dongpu1881 2019-01-03 22:24
浏览 84

在Go中查找隐藏的矿工(隐藏的Windows +命令行)

I found this C# and I want to improve on it in Go: https://github.com/roachadam/MinerKiller/blob/master/MinerKiller/MinerKiller.cs

My first question, is how do I detect if a process window is hidden. ie this code:

if (p.MainWindowHandle == IntPtr.Zero )

My Second question is how to get the command line of a process. ie this C# code

private string GetCommandLine(Process process)
{
     string cmdLine = null;
     using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
     {
          var matchEnum = searcher.Get().GetEnumerator();
          if (matchEnum.MoveNext())
          {
              cmdLine = matchEnum.Current["CommandLine"]?.ToString();
          }
      }
      return cmdLine;
}
  • 写回答

1条回答 默认 最新

  • douyiji3919 2019-01-03 23:52
    关注

    While the go standard library's os package provides a lot of nice utilities for interfacing with operating system functionality, they are much "lower level" then what you are referencing from the .NET System.Management classes. You will most likely have to implement the behavior of these classes yourself to achieve the desired outcome (using the tool from Go's os package as your primary "building blocks")

    That said, there is a psutil port in Go (gopsutil - https://github.com/shirou/gopsutil/) that provides utilities for retrieving info on running processes as well as system utilization. This will most likely provide the higher level abstraction you can use to implement your program.

    If gopsutil is too opinionated or high level for you needs, I would also check out the operating system specific packages in the golang subrepositories.

    Documented here: https://godoc.org/golang.org/x/sys

    Source here: https://github.com/golang/sys/

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办