Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Новый участник


Сообщения: 2
Благодарности: 0

Профиль | Отправить PM | Цитировать


Цитата amel27:
Creat0R, не пойму зачем EnumProcessModules, и без нее вроде работает...
Код: Выделить весь код
$sProcess = "svchost.exe"
$sFilePath = _WinAPI_ProcessGetFilePath($sProcess)
If @error Then Exit MsgBox(16, "Ошибка", "код ошибки:"&@TAB& @error &@CRLF&"расширение:"&@TAB& @extended)
MsgBox(0, "Сообщение", "процесс:"&@TAB& $sProcess &@CRLF&"путь:"&@TAB& $sFilePath)
Func _WinAPI_ProcessGetFilePath($process)
 $process = ProcessExists($process)
 If $process =0 Then Return SetError(1, 0, "") ; ОШИБКА: процесс не найден
 ; Открытие процесса
 Local $aRet = DllCall('kernel32.dll', 'ptr', 'OpenProcess', _
 'int', BitOR(0x400,0x10), 'int', 0, 'int', $process)
 Local $hProc = $aRet[0], $tFilePath = DllStructCreate("char[300]")
 If $aRet[0]=0 Then
 $aRet = DllCall('kernel32.dll', 'int', 'GetLastError')
 Return SetError(2, $aRet[0], "") ; ОШИБКА открытия процесса
 EndIf
 ; Получение пути к файлу образа
 $aRet = DllCall("Psapi.dll", "dword", "GetModuleFileNameEx", _
 "ptr", $hProc, "ptr", 0, "ptr", DllStructGetPtr($tFilePath), "dword", 300)
 If $aRet=0 Then
 $aRet = DllCall('kernel32.dll', 'int', 'GetLastError')
 Return SetError(3, $aRet[0], "") ; ОШИБКА получения имени
 EndIf
 ; Закрытие описателя и возврат значения
 DllCall('kernel32.dll','ptr', 'CloseHandle','ptr', $hProc)
 Return DllStructGetData($tFilePath, 1)
EndFunc ;==> _WinAPI_ProcessGetFilePath
Спасибо, то что надо!

Отправлено: 10:13, 17-04-2009 | #5