【问题标题】:Get Threads Start Address with Powershell使用 Powershell 获取线程起始地址
【发布时间】:2020-10-27 21:22:23
【问题描述】:

我有任务,需要从选定的进程或选定的线程中获取线程起始地址。

$result = Get-Process -Name notepad -IncludeUserName

$Threads =@()
    foreach ($ID in $result)
     {
        $Threads += Get-Process -ID $ID.ID | Select-Object -ExpandProperty  Threads | Select-Object ID
     }

我可以得到这样的数据

但是启动地址线程没有像在 Process Explorer 上那样获得信息。

我找到了C#Low-Level Windows API Access 的一些示例,就像我看到了这个解决方案一样,但我需要帮助来采用脚本Kernel32 : : CreateProcessC++ 上获取PROCESS_INFORMATION 并最终获得线程的起始地址。

谁能帮帮我?

我不认为这个任务只能通过 Powershell 来解决,所以我放宽了眼界,在 powershell 脚本中运行 C# 或 C++ 代码看到了解决方案。 p>

【问题讨论】:

  • 不,我没有关于 C# 的示例

标签: c# c++ powershell


【解决方案1】:

你必须再深入一点:

PS> $x = Get-Process

PS> $x[0].mainmodule

   Size(K) ModuleName                                         FileName                                                            
   ------- ----------                                         --------                                                            
      2168 chrome.exe                                         C:\Program Files (x86)\Google\Chrome\Application\chrome.exe         



PS> $x[0].mainmodule | gm


   TypeName: System.Diagnostics.ProcessModule

Name                      MemberType     Definition                                                              
----                      ----------     ----------                                                              
Disposed                  Event          System.EventHandler Disposed(System.Object, System.EventArgs)           
CreateObjRef              Method         System.Runtime.Remoting.ObjRef CreateObjRef(type requestedType)         
Dispose                   Method         void Dispose(), void IDisposable.Dispose()                              
Equals                    Method         bool Equals(System.Object obj)                                          
GetHashCode               Method         int GetHashCode()                                                       
GetLifetimeService        Method         System.Object GetLifetimeService()                                      
GetType                   Method         type GetType()                                                          
InitializeLifetimeService Method         System.Object InitializeLifetimeService()                               
ToString                  Method         string ToString()                                                       
BaseAddress               Property       System.IntPtr BaseAddress {get;}                                        
Container                 Property       System.ComponentModel.IContainer Container {get;}                       
EntryPointAddress         Property       System.IntPtr EntryPointAddress {get;}                                  
FileName                  Property       string FileName {get;}                                                  
FileVersionInfo           Property       System.Diagnostics.FileVersionInfo FileVersionInfo {get;}               
ModuleMemorySize          Property       int ModuleMemorySize {get;}                                             
ModuleName                Property       string ModuleName {get;}                                                
Site                      Property       System.ComponentModel.ISite Site {get;set;}                             
Company                   ScriptProperty System.Object Company {get=$this.FileVersionInfo.CompanyName;}          
Description               ScriptProperty System.Object Description {get=$this.FileVersionInfo.FileDescription;}  
FileVersion               ScriptProperty System.Object FileVersion {get=$this.FileVersionInfo.FileVersion;}      
Product                   ScriptProperty System.Object Product {get=$this.FileVersionInfo.ProductName;}          
ProductVersion            ScriptProperty System.Object ProductVersion {get=$this.FileVersionInfo.ProductVersion;}
Size                      ScriptProperty System.Object Size {get=$this.ModuleMemorySize / 1024;}                 

PS> $x[0].mainmodule.BaseAddress
140699046510592

我认为 BaseAddress 是您想要的属性。

【讨论】:

  • 谢谢。这与我正在寻找的有点不同,它是进程的基本模块,我需要进程的线程。我在问题中添加了一张图片。
猜你喜欢
  • 2018-12-18
  • 2011-01-04
  • 1970-01-01
  • 1970-01-01
  • 2016-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多