Ver Mensaje Individual
  #4 (permalink)  
Antiguo 11/10/2009, 10:57
Avatar de seba123neo
seba123neo
 
Fecha de Ingreso: febrero-2007
Ubicación: Esperanza, Santa Fe
Mensajes: 1.046
Antigüedad: 18 años, 3 meses
Puntos: 19
Respuesta: Linea de comandos (procesos)

Hola, proba esto:

Código vb:
Ver original
  1. Option Explicit
  2.  
  3. Private Type OBJECT_ATTRIBUTES
  4.     Length As Long
  5.     RootDirectory As Long
  6.     ObjectName As Long
  7.     Attributes As Long
  8.     SecurityDescriptor As Long
  9.     SecurityQualityOfService As Long
  10. End Type
  11.  
  12. Private Type CLIENT_ID
  13.     UniqueProcess As Long
  14.     UniqueThread  As Long
  15. End Type
  16.  
  17. Private Declare Function NtOpenProcess Lib "NTDLL.DLL" (ByRef ProcessHandle As Long, ByVal AccessMask As Long, ByRef ObjectAttributes As OBJECT_ATTRIBUTES, ByRef ClientID As CLIENT_ID) As Long
  18. Private Declare Function NtClose Lib "NTDLL.DLL" (ByVal ObjectHandle As Long) As Long
  19. Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
  20. Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
  21. Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
  22. Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
  23. Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
  24.  
  25. Private Function GetProcessCommandLine(ByVal dwProcessId As Long) As String
  26.     Dim objCid As CLIENT_ID
  27.     Dim objOa As OBJECT_ATTRIBUTES
  28.     Dim ntStatus As Long, hKernel As Long, strName As String
  29.     Dim hProcess As Long, dwAddr As Long, dwRead As Long
  30.     objOa.Length = Len(objOa)
  31.     objCid.UniqueProcess = dwProcessId
  32.     ntStatus = NtOpenProcess(hProcess, &H10, objOa, objCid)
  33.     If hProcess = 0 Then
  34.         GetProcessCommandLine = "[Not Available]"
  35.         Exit Function
  36.     End If
  37.     hKernel = GetModuleHandle("kernel32")
  38.     dwAddr = GetProcAddress(hKernel, "GetCommandLineA")
  39.     CopyMemory dwAddr, ByVal dwAddr + 1, 4
  40.     If ReadProcessMemory(hProcess, ByVal dwAddr, dwAddr, 4, dwRead) Then
  41.         strName = String(260, Chr(0))
  42.         If ReadProcessMemory(hProcess, ByVal dwAddr, ByVal strName, 260, dwRead) Then
  43.             strName = Left(strName, InStr(strName, Chr(0)) - 1)
  44.             GetProcessCommandLine = strName
  45.         End If
  46.     End If
  47.     NtClose hProcess
  48. End Function
  49.  
  50. Private Sub Form_Load()
  51.     MsgBox GetProcessCommandLine(GetCurrentProcessId())
  52. End Sub

saludos.
__________________
" Todos Somos Ignorantes; lo que pasa es que no todos ignoramos las mismas cosas " - Albert Einstein