zoukankan      html  css  js  c++  java
  • Atitit,通过pid获取进程文件路径 java php  c#.net版本大总结

    Atitit,通过pid获取进程文件路径 java php  c#.net版本大总结

     

     

    1通过PID获取进程路径的几种方法2

    1.1. GetModuleFileNameEx 想获得进程可执行文件的路径最常用的方法是通过GetModuleFileNameEx函数获得可执行文件的模块路径这个函数从Windows NT 4.0开始到现在的Vista系统都能使用,向后兼容性比较好。2

    1.2. 第二种方法是GetProcessImageFileName函数,这个函数在Windows XP及其以后的系统中都能使用,使用此函数返回的路径不是通常的系统盘符,如"C:...",而是驱动层的表示方式"DeviceHarddiskVolume1...",所以使用起来不是很方便。2

    1.3. 第三种方法是使用Windows Vista新增的函数QueryFullProcessImageName,由于是Vista新增的,所以兼容性不好。2

    2使用powershell  相等于调用System.Diagnostics.Process2

    2.1. Get-Process -id 6712 -FileVersionInfo2

    2.1.1. -FileVersionInfo3

    2.2. C#.net版本3

    2.3. Note3

    3获取加载的dll模块列表    Get-Process -id 6712 -Module3

    4参考10

     

     

    1. 通过PID获取进程路径的几种方法

    1.1. GetModuleFileNameEx
    想获得进程可执行文件的路径最常用的方法是通过GetModuleFileNameEx函数获得可执行文件的模块路径这个函数从Windows NT 4.0开始到现在的Vista系统都能使用,向后兼容性比较好。

    1.2. 第二种方法是GetProcessImageFileName函数,这个函数在Windows XP及其以后的系统中都能使用,使用此函数返回的路径不是通常的系统盘符,如"C:...",而是驱动层的表示方式"DeviceHarddiskVolume1...",所以使用起来不是很方便。

    1.3. 第三种方法是使用Windows Vista新增的函数QueryFullProcessImageName,由于是Vista新增的,所以兼容性不好。

     

    2. 使用powershell  相等于调用System.Diagnostics.Process

    2.1.  Get-Process -id 6712 -FileVersionInfo 

     

     

    PS C:Windowswinsxsamd64_microsoft-windows-gpowershell-exe_31bf3856ad364e35_6.1.7600.16385_none_94861149bb66249c>  Get-Process -id 6712 -FileVersionInfo 

     

    ProductVersion   FileVersion      FileName                                                                                                                                                                                                                                                                               

    --------------   -----------      --------                                                                                                                                                                                                                                                                               

                                      C:eclipseeclipse.exe        

     

     

     

     

     

    2.1.1. -FileVersionInfo 

    获取进程中运行的程序的文件版本信息。

    在 Windows Vista 以及更高版本的 Windows 上,必须使用“以管理员身份运行”选项打开 Windows PowerShell,才能对您不具有所有权的进程使用此参数。

    使用此参数等效于获取每个进程对象的 MainModule.FileVersionInfo 属性。如果使用此参数,则 Get-Process 返回 FileVersionInfo 对象 (System.Diagnostics.FileVersionInfo),而非进程对象。因此,不能通过管道将命令输出传递到需要进程对象的 cmdlet(例如 Stop-Process)。

     

     

    作者:: 绰号:老哇的爪子 ( 全名::Attilax akbar al rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙,  EMAIL:1466519819@qq.com

     

    2.2. C#.net版本

    //根据名称获取进程
    Process[] ps = Process.GetProcessesByName("NameStr");
    foreach (Process p in ps)
    {
    //输出进程路径
    Console.WriteLine(p.MainModule.FileName);
    }

     

    2.3. Note

    需要先设置权限RemoteSigned前面有空格与set-ExecutionPolicy 隔开

    set-ExecutionPolicy        RemoteSigned

    3. 获取加载的dll模块列表    Get-Process -id 6712 -Module  

     

    PS C:Windowswinsxsamd64_microsoft-windows-gpowershell-exe_31bf3856ad364e35_6.1.7600.16385_none_94861149bb66249c>  Get-Process -id 6712 -Module  

     

       Size(K) ModuleName                                         FileName                                                                                                                                                                                                                                                   

       ------- ----------                                         --------                                                                                                                                                                                                                                                   

           316 eclipse.exe                                        C:eclipseeclipse.exe                                                                                                                                                                                                                                     

          1700 ntdll.dll                                          C:WindowsSYSTEM32 tdll.dll                                                                                                                                                                                                                              

          1152 kernel32.dll                                       C:Windowssystem32kernel32.dll                                                                                                                                                                                                                           

           432 KERNELBASE.dll                                     C:Windowssystem32KERNELBASE.dll                                                                                                                                                                                                                         

          1000 USER32.dll                                         C:Windowssystem32USER32.dll                                                                                                                                                                                                                             

           412 GDI32.dll                                          C:Windowssystem32GDI32.dll                                                                                                                                                                                                                              

            56 LPK.dll                                            C:Windowssystem32LPK.dll                                                                                                                                                                                                                                

           808 USP10.dll                                          C:Windowssystem32USP10.dll                                                                                                                                                                                                                              

           636 msvcrt.dll                                         C:Windowssystem32msvcrt.dll                                                                                                                                                                                                                             

          2000 COMCTL32.dll                                       C:WindowsWinSxSamd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18837_none_fa3b1e3d17594757COMCTL32.dll                                                                                                                               

           452 SHLWAPI.dll                                        C:Windowssystem32SHLWAPI.dll                                                                                                                                                                                                                            

           184 IMM32.DLL                                          C:Windowssystem32IMM32.DLL                                                                                                                                                                                                                              

          1060 MSCTF.dll                                          C:Windowssystem32MSCTF.dll                                                                                                                                                                                                                              

            72 eclipse_1608.dll                                   C:eclipsepluginsorg.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316eclipse_1608.dll                                                                                                                                                 

           876 ADVAPI32.dll                                       C:Windowssystem32ADVAPI32.dll                                                                                                                                                                                                                           

           124 sechost.dll                                        C:WindowsSYSTEM32sechost.dll                                                                                                                                                                                                                            

          1204 RPCRT4.dll                                         C:Windowssystem32RPCRT4.dll                                                                                                                                                                                                                             

            48 VERSION.dll                                        C:Windowssystem32VERSION.dll                                                                                                                                                                                                                            

           344 uxtheme.dll                                        C:Windowssystem32uxtheme.dll                                                                                                                                                                                                                            

          2060 ole32.dll                                          C:Windowssystem32ole32.dll                                                                                                                                                                                                                              

            60 CRYPTBASE.dll                                      C:Windowssystem32CRYPTBASE.dll                                                                                                                                                                                                                          

          8552 jvm.dll                                            C:eclipsejreinserverjvm.dll                                                                                                                                                                                                                          

            36 WSOCK32.dll                                        C:Windowssystem32WSOCK32.dll                                                                                                                                                                                                                            

           308 WS2_32.dll                                         C:Windowssystem32WS2_32.dll                                                                                                                                                                                                                             

            32 NSI.dll                                            C:Windowssystem32NSI.dll                                                                                                                                                                                                                                

           236 WINMM.dll                                          C:Windowssystem32WINMM.dll                                                                                                                                                                                                                              

            28 PSAPI.DLL                                          C:Windowssystem32PSAPI.DLL                                                                                                                                                                                                                              

           840 MSVCR100.dll                                       C:Windowssystem32MSVCR100.dll                                                                                                                                                                                                                           

            60 verify.dll                                         C:eclipsejreinverify.dll                                                                                                                                                                                                                              

           160 java.dll                                           C:eclipsejreinjava.dll                                                                                                                                                                                                                                

            88 zip.dll                                            C:eclipsejreinzip.dll                                                                                                                                                                                                                                 

         13860 SHELL32.dll                                        C:Windowssystem32SHELL32.dll                                                                                                                                                                                                                            

            60 profapi.dll                                        C:Windowssystem32profapi.dll                                                                                                                                                                                                                            

            96 CRYPTSP.dll                                        C:Windowssystem32CRYPTSP.dll                                                                                                                                                                                                                            

           284 rsaenh.dll                                         C:Windowssystem32 saenh.dll                                                                                                                                                                                                                             

           120 USERENV.dll                                        C:Windowssystem32USERENV.dll                                                                                                                                                                                                                            

           104 net.dll                                            C:eclipsejrein et.dll                                                                                                                                                                                                                                 

          1036 AcSpi64.dll                                        C:Windowssystem32AcSpi64.dll                                                                                                                                                                                                                            

           860 OLEAUT32.dll                                       C:Windowssystem32OLEAUT32.dll                                                                                                                                                                                                                           

            68 WTSAPI32.dll                                       C:Windowssystem32WTSAPI32.dll                                                                                                                                                                                                                           

           452 WINHTTP.dll                                        C:Windowssystem32WINHTTP.dll                                                                                                                                                                                                                            

           400 webio.dll                                          C:Windowssystem32webio.dll                                                                                                                                                                                                                              

          1200 PROPSYS.dll                                        C:Windowssystem32PROPSYS.dll                                                                                                                                                                                                                            

           340 mswsock.dll                                        C:Windowssystem32mswsock.dll                                                                                                                                                                                                                            

            28 wship6.dll                                         C:WindowsSystem32wship6.dll                                                                                                                                                                                                                             

          1884 SETUPAPI.dll                                       C:Windowssystem32SETUPAPI.dll                                                                                                                                                                                                                           

           216 CFGMGR32.dll                                       C:Windowssystem32CFGMGR32.dll                                                                                                                                                                                                                           

           104 DEVOBJ.dll                                         C:Windowssystem32DEVOBJ.dll                                                                                                                                                                                                                             

           156 IPHLPAPI.DLL                                       C:Windowssystem32IPHLPAPI.DLL                                                                                                                                                                                                                           

            44 WINNSI.DLL                                         C:Windowssystem32WINNSI.DLL                                                                                                                                                                                                                             

            68 dhcpcsvc6.DLL                                      C:Windowssystem32dhcpcsvc6.DLL                                                                                                                                                                                                                          

            96 dhcpcsvc.DLL                                       C:Windowssystem32dhcpcsvc.DLL                                                                                                                                                                                                                           

            68 nio.dll                                            C:eclipsejrein io.dll                                                                                                                                                                                                                                 

            84 NLAapi.dll                                         C:Windowssystem32NLAapi.dll                                                                                                                                                                                                                             

            84 napinsp.dll                                        C:Windowssystem32 apinsp.dll                                                                                                                                                                                                                            

           100 pnrpnsp.dll                                        C:Windowssystem32pnrpnsp.dll                                                                                                                                                                                                                            

           364 DNSAPI.dll                                         C:Windowssystem32DNSAPI.dll                                                                                                                                                                                                                             

            44 winrnr.dll                                         C:WindowsSystem32winrnr.dll                                                                                                                                                                                                                             

           152 mdnsNSP.dll                                        C:Program FilesBonjourmdnsNSP.dll                                                                                                                                                                                                                       

            28 wshtcpip.dll                                       C:WindowsSystem32wshtcpip.dll                                                                                                                                                                                                                           

            32 rasadhlp.dll                                       C:Windowssystem32 asadhlp.dll                                                                                                                                                                                                                           

           332 fwpuclnt.dll                                       C:WindowsSystem32fwpuclnt.dll                                                                                                                                                                                                                           

           672 swt-win32-4430.dll                                 C:eclipseconfigurationorg.eclipse.osgi869.cpswt-win32-4430.dll                                                                                                                                                                                     

           604 comdlg32.dll                                       C:Windowssystem32comdlg32.dll                                                                                                                                                                                                                           

           452 WINSPOOL.DRV                                       C:Windowssystem32WINSPOOL.DRV                                                                                                                                                                                                                           

          1388 WININET.dll                                        C:Windowssystem32WININET.dll                                                                                                                                                                                                                            

            12 Normaliz.dll                                       C:Windowssystem32Normaliz.dll                                                                                                                                                                                                                           

          2120 iertutil.dll                                       C:Windowssystem32iertutil.dll                                                                                                                                                                                                                           

          1372 urlmon.dll                                         C:Windowssystem32urlmon.dll                                                                                                                                                                                                                             

          1460 CRYPT32.dll                                        C:Windowssystem32CRYPT32.dll                                                                                                                                                                                                                            

            60 MSASN1.dll                                         C:Windowssystem32MSASN1.dll                                                                                                                                                                                                                             

            96 dwmapi.dll                                         C:Windowssystem32dwmapi.dll                                                                                                                                                                                                                             

           612 CLBCatQ.DLL                                        C:Windowssystem32CLBCatQ.DLL                                                                                                                                                                                                                            

            48 LINKINFO.dll                                       C:Windowssystem32LINKINFO.dll                                                                                                                                                                                                                           

           120 swt-gdip-win32-4430.dll                            C:eclipseconfigurationorg.eclipse.osgi869.cpswt-gdip-win32-4430.dll                                                                                                                                                                                

          2136 gdiplus.dll                                        C:WindowsWinSxSamd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.19061_none_2b299db671e86e03gdiplus.dll                                                                                                                                        

          1192 WindowsCodecs.dll                                  C:Windowssystem32WindowsCodecs.dll                                                                                                                                                                                                                      

            72 localfile_1_0_0.dll                                C:eclipseconfigurationorg.eclipse.osgi72.cposwin32x86_64localfile_1_0_0.dll                                                                                                                                                                     

            68 jWinHttp-1.0.0.dll                                 C:eclipseconfigurationorg.eclipse.osgi75.cpjWinHttp-1.0.0.dll                                                                                                                                                                                      

           336 oleacc.dll                                         C:Windowssystem32oleacc.dll                                                                                                                                                                                                                             

            28 msimg32.dll                                        C:Windowssystem32msimg32.dll                                                                                                                                                                                                                            

           236 mlang.dll                                          C:Windowssystem32mlang.dll                                                                                                                                                                                                                              

           144 sunec.dll                                          C:eclipsejreinsunec.dll                                                                                                                                                                                                                               

            80 RpcRtRemote.dll                                    C:Windowssystem32RpcRtRemote.dll                                                                                                                                                                                                                        

           348 apphelp.dll                                        C:Windowssystem32apphelp.dll                                                                                                                                                                                                                            

          1832 explorerframe.dll                                  C:Windowssystem32explorerframe.dll                                                                                                                                                                                                                      

           268 DUser.dll                                          C:Windowssystem32DUser.dll                                                                                                                                                                                                                              

           968 DUI70.dll                                          C:Windowssystem32DUI70.dll                                                                                                                                                                                                                              

           180 ntmarta.dll                                        C:Windowssystem32 tmarta.dll                                                                                                                                                                                                                            

           328 WLDAP32.dll                                        C:Windowssystem32WLDAP32.dll                                                                                                                                                                                                                            

           512 ntshrui.dll                                        C:Windowssystem32 tshrui.dll                                                                                                                                                                                                                            

           140 srvcli.dll                                         C:Windowssystem32srvcli.dll                                                                                                                                                                                                                             

            60 cscapi.dll                                         C:Windowssystem32cscapi.dll                                                                                                                                                                                                                             

            44 slc.dll                                            C:Windowssystem32slc.dll                                                                                                                                                                                                                                

            48 netutils.dll                                       C:Windowssystem32 etutils.dll                                                                                                                                                                                                                           

         10704 ieframe.dll                                        C:WindowsSystem32ieframe.dll                                                                                                                                                                                                                            

           580 SXS.DLL                                            C:Windowssystem32SXS.DLL                                                                                                                                                                                                                                

            44 Secur32.dll                                        C:Windowssystem32Secur32.dll                                                                                                                                                                                                                            

           148 SSPICLI.DLL                                        C:Windowssystem32SSPICLI.DLL                                                                                                                                                                                                                            

         17492 mshtml.dll                                         C:WindowsSystem32mshtml.dll                                                                                                                                                                                                                             

            56 msimtf.dll                                         C:Windowssystem32msimtf.dll                                                                                                                                                                                                                             

           232 msls31.dll                                         C:Windowssystem32msls31.dll                                                                                                                                                                                                                             

           904 d2d1.dll                                           C:Windowssystem32d2d1.dll                                                                                                                                                                                                                               

          1532 DWrite.dll                                         C:Windowssystem32DWrite.dll                                                                                                                                                                                                                             

           668 dxgi.dll                                           C:Windowssystem32dxgi.dll                                                                                                                                                                                                                               

           236 WINTRUST.dll                                       C:Windowssystem32WINTRUST.dll                                                                                                                                                                                                                           

           208 d3d10_1.dll                                        C:Windowssystem32d3d10_1.dll                                                                                                                                                                                                                            

           340 d3d10_1core.dll                                    C:Windowssystem32d3d10_1core.dll                                                                                                                                                                                                                        

          1856 D3D10Warp.dll                                      C:Windowssystem32D3D10Warp.dll                                                                                                                                                                                                                          

          1268 d3d10.dll                                          C:Windowssystem32d3d10.dll                                                                                                                                                                                                                              

           300 d3d10core.dll                                      C:Windowssystem32d3d10core.dll                                                                                                                                                                                                                          

          4016 GOOGLEPINYIN2.IME                                  C:Windowssystem32GOOGLEPINYIN2.IME                                                                                                                                                                                                                      

          1172 dbghelp.dll                                        C:Windowssystem32dbghelp.dll                                                                                                                                                                                                                            

           136 bcrypt.dll                                         C:WindowsSystem32crypt.dll                                                                                                                                                                                                                             

           304 bcryptprimitives.dll                               C:Windowssystem32cryptprimitives.dll                                                                                                                                                                                                                   

           152 360CloudShellExt64.dll                             C:Program Files (x86)360WangPanCloudMini360CloudShellExt64.dll                                                                                                                                                                                         

           468 QMGCShellExt64.dll                                 C:Program Files (x86)QQPCMgr11.2.17063.223QMGCShellExt64.dll                                                                                                                                                                                           

          1060 MSVCP80.dll                                        C:WindowsWinSxSamd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6229_none_88dcc0bf2fb1b808MSVCP80.dll                                                                                                                                               

           804 MSVCR80.dll                                        C:WindowsWinSxSamd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6229_none_88dcc0bf2fb1b808MSVCR80.dll                                                                                                                                               

           664 exnscan64.dll                                      C:Program Files (x86)QQPCMgr11.2.17063.223exnscan64.dll                                                                                                                                                                                                

            88 NETAPI32.dll                                       C:Windowssystem32NETAPI32.dll                                                                                                                                                                                                                           

            84 wkscli.dll                                         C:Windowssystem32wkscli.dll                                                                                                                                                                                                                             

           212 EhStorShell.dll                                    C:Windowssystem32EhStorShell.dll                                                                                                                                                                                                                        

          1428 jd-eclipse.dll                                     C:eclipseconfigurationorg.eclipse.osgi761.cpwin32x86_64jd-eclipse.dll                                                                                                                                                                            

           652 MSVCR90.dll                                        C:WindowsWinSxSamd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.7523_none_08e1eaf5a83f8ea2MSVCR90.dll                                                                                                                                               

     

     

    4. 参考

    通过PID获取进程路径的几种方法 安静的主页.htm

    paip. c++ 调用.net dll 最好方式powershell 使用总结. - attilax的专栏 博客频道 - CSDN.NET.htm

  • 相关阅读:
    使用python写天气预告
    beef配合ettercap批量劫持内网的浏览器
    html布局
    python 使用paramiko模块上传本地文件到ssh
    mysql一些函数的记录
    python与ssh交互
    html笔记4
    html笔记3
    html笔记2
    html笔记1
  • 原文地址:https://www.cnblogs.com/attilax/p/5963564.html
Copyright © 2011-2022 走看看