测试4#的代码系统OVER了,弹出一个错误对话框,没等点击就关机了,貌似几个系统关键进程出现了问题。
关闭远程进程中的句柄根本不需要HOOK,DuplicateHandle如果不能实现这个功能的话,那它就不强大了。
枚举句柄可以参考一下Thread.au3中的_RTEnumerateHandles,可以指定参数,用于标识枚举哪个进程中的句柄。
既然楼主兄独立思考过了,那就把解决方案贴出来。以下这段代码可以实现QQGame的无限多开。
#include <Thread.au3>
Const $tagSYSTEM_HANDLE_INFORMATION = "ulong ProcessId;ubyte ObjType;ubyte Flags;ushort Handle;ptr Object;dword DesiredAccess"
$aProcess = ProcessList("QQGame.exe")
If ($aProcess[0][0]) Then
For $i = 1 To $aProcess[0][0]
Assign("~" & $aProcess[$i][1], _RTOpenProcess($aProcess[$i][1]))
Next
Else
Exit
EndIf
$sObjName = "\BaseNamedObjects\QQGame_Mutex03/01/2003"
$pBuffer = _RTHeapAlloc(1024)
_RTQuerySystemInformation(16, $pBuffer, 1024)
$iBuffer = @Extended
_RTHeapFree($pBuffer)
$pBuffer = _RTHeapAlloc($iBuffer)
_RTQuerySystemInformation(16, $pBuffer, $iBuffer)
$iNumberofHandles = _RTReadBytes($pBuffer)
$pBuffer += 4
$pObjName = _RTHeapAlloc(1024)
For $i = 1 To $iNumberofHandles
$tBuffer = DllStructCreate($tagSYSTEM_HANDLE_INFORMATION, $pBuffer + ($i - 1) * 16)
If Not IsDeclared("~" & DllStructGetData($tBuffer, "ProcessId")) Then
$tBuffer = 0
ContinueLoop
EndIf
$hProcess = Eval("~" & DllStructGetData($tBuffer, "ProcessId"))
$hHandle = DllStructGetData($tBuffer, "Handle")
$hDup = _RTDuplicateHandle($hProcess, $hHandle, -1)
If _RTQueryObject($hDup, 1, $pObjName, 1024) Then
If _RTInitBufferExW($pObjName) = $sObjName Then
_RTCloseHandle($hDup)
_RTCloseHandle(_RTDuplicateHandle($hProcess, $hHandle, -1, 1))
ExitLoop
EndIf
EndIf
_RTCloseHandle($hDup)
$tBuffer = 0
Next
_RTHeapFree($pBuffer)
_RTHeapFree($pObjName)
For $i = 1 To $aProcess[0][0]
_RTCloseHandle(Eval("~" & $aProcess[$i][1]))
Next
MsgBox(48, "Bingo~", "Done~!~!")
Thread.au3 - http://www.autoitx.com/thread-18153-1-1.html |