找回密码
 加入
搜索
查看: 6327|回复: 11

[网络通信] 解决了

 火.. [复制链接]
发表于 2014-12-6 15:48:10 | 显示全部楼层 |阅读模式
本帖最后由 繁星 于 2015-4-22 12:17 编辑

解决了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-12-6 16:26:38 | 显示全部楼层
找pid干什么
 楼主| 发表于 2014-12-6 16:34:44 | 显示全部楼层
回复 2# netegg

通过找到PID来结束进程啊,因为ProcessClose结束指定进程的时候,如遇多个进程的名称相同, 则 PID 最高的进程将被结束 - 并不是以最近启动的进程为准.所以我才找PID想要准备的结束进程
发表于 2014-12-6 16:39:30 | 显示全部楼层
processlist
_arraysort
processclose
发表于 2014-12-6 16:41:05 | 显示全部楼层
这个用不着api
 楼主| 发表于 2014-12-6 17:06:01 | 显示全部楼层
回复 5# netegg

如果是PING命令 ,会有两个进程,一个cmd,一个Ping ,ProcessList就不能返回当前运行进程的名称和 PID 值的数组.
发表于 2014-12-6 17:18:07 | 显示全部楼层
回复 6# 繁星
你不是有进程名吗,管这些干吗?,进程名出来,pid也出来了
发表于 2014-12-6 17:22:24 | 显示全部楼层
你都有地址了,直接结束文件名不就OK了~
发表于 2014-12-6 19:24:24 | 显示全部楼层
回复 6# 繁星


   明显是只会"抄写"的新手. 这么小的数组,直接遍历搜出来就是了.
Local $sSch = 'c:\windows\explorer.exe'
Local $sPIDS = ''
Local $sPath
For $i=1 to ubound($list,1)-1
        $sPath = _WinAPI_GetCommandLineFromPID($list[$i][1])
        If  $sPath = $sSch Then $sPIDS &= @CRLF & $sPath                  
Next
MsgBox(0, $sSch, 'PID:' & $sPIDS)
发表于 2014-12-6 20:17:52 | 显示全部楼层
借3000大侠的码,我给你补个完整的吧~~
#include <WinAPI.au3>
#include <array.au3>

Global Const $PROCESS_VM_READ=0x10
Global Const $PROCESS_QUERY_INFORMATION = 0x400
_GetPrivilege_SEDEBUG()
$list=ProcessList()
Redim $list[ubound($list,1)][3]

Local $sSch = InputBox("请输入完整的路径", @CRLF & '例如:c:\windows\explorer.exe','c:\windows\explorer.exe')
Local $sPIDS = ''
Local $sPath
For $i=1 to ubound($list,1)-1
        $sPath = _WinAPI_GetCommandLineFromPID($list[$i][1])
        If  $sPath = $sSch Then $sPIDS &= $list[$i][1]             
Next
MsgBox(0, $sSch, $sSch & @CRLF & 'PID:' & $sPIDS)



Func _WinAPI_GetCommandLineFromPID($PID)
    $ret1=DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', $PROCESS_VM_READ+$PROCESS_QUERY_INFORMATION, 'int', False, 'int', $PID)
    $tag_PROCESS_BASIC_INFORMATION = "int ExitStatus;" & _
                                     "ptr PebBaseAddress;" & _
                                     "ptr AffinityMask;" & _
                                     "ptr BasePriority;" & _
                                     "ulong UniqueProcessId;" & _
                                     "ulong InheritedFromUniqueProcessId;"
    $PBI=DllStructCreate($tag_PROCESS_BASIC_INFORMATION)
    DllCall("ntdll.dll", "int", "ZwQueryInformationProcess", "hwnd", $ret1[0], "int", 0, "ptr", DllStructGetPtr($PBI), "int", _
                                                                                                DllStructGetSize($PBI), "int",0)
    $dw=DllStructCreate("ptr")
    DllCall("kernel32.dll", "int", "ReadProcessMemory", "hwnd", $ret1[0], _
                            "ptr", DllStructGetData($PBI,2)+0x10, _
                            "ptr", DllStructGetPtr($dw), "int", 4, "ptr", 0)
    $unicode_string = DllStructCreate("ushort Length;ushort MaxLength;ptr String")
    DllCall("kernel32.dll", "int", "ReadProcessMemory", "hwnd", $ret1[0], _
                                 "ptr", DllStructGetData($dw, 1)+0x40, _
                                 "ptr", DllStructGetPtr($unicode_string), "int", DllStructGetSize($unicode_string), "ptr", 0)
    $ret=DllCall("kernel32.dll", "int", "ReadProcessMemory", "hwnd", $ret1[0], _
                                 "ptr", DllStructGetData($unicode_string, "String"), _
                                 "wstr", 0, "int", DllStructGetData($unicode_string, "Length") + 2, "int*", 0)
    DllCall("kernel32.dll", 'int', 'CloseHandle', "hwnd", $ret1[0])
    If $ret[5] Then Return $ret[3]
    Return ""
EndFunc

Func _GetPrivilege_SEDEBUG()
    Local $tagLUIDANDATTRIB = "int64 Luid;dword Attributes"
    Local $count = 1
    Local $tagTOKENPRIVILEGES = "dword PrivilegeCount;byte LUIDandATTRIB[" & $count * 12 & "]"
    Local $TOKEN_ADJUST_PRIVILEGES = 0x20
    Local $call = DllCall("advapi32.dll", "int", "OpenProcessToken", "ptr", _WinAPI_GetCurrentProcess(), "dword", $TOKEN_ADJUST_PRIVILEGES, "ptr*", "")
    Local $hToken = $call[3]
    $call = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", Chr(0), "str", "SeDebugPrivilege", "int64*", "")
    Local $iLuid = $call[3]
    Local $TP = DllStructCreate($tagTOKENPRIVILEGES)
    Local $LUID = DllStructCreate($tagLUIDANDATTRIB, DllStructGetPtr($TP, "LUIDandATTRIB"))
    DllStructSetData($TP, "PrivilegeCount", $count)
    DllStructSetData($LUID, "Luid", $iLuid)
    DllStructSetData($LUID, "Attributes", $SE_PRIVILEGE_ENABLED)
    $call = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "ptr", $hToken, "int", 0, "ptr", DllStructGetPtr($TP), "dword", 0, "ptr", Chr(0), "ptr", Chr(0))
    Return ($call[0] <> 0)
EndFunc
发表于 2014-12-10 08:24:55 | 显示全部楼层
$list = progresslist($progressname)
_arrausort($list,1)
progressclose($list[0])
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 12:21 , Processed in 0.082259 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表