Autor
|
Tema: Path (SRC) (Leído 2,176 veces)
|
Dessa
Desconectado
Mensajes: 624
|
Una boludez, pero a veces puede servir, con este code se puede saber la ruta (Path) del ejetutable al que pertenece a una ventana, solo hay que pasar el puntero del mouse sobre la ventana que se quiere "investigar". Option Explicit Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long 'Dessa Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwprocessid As Long) As Long Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function GetModuleFileNameExA Lib "PSAPI.DLL" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Type POINTAPI: x As Long: y As Long: End Type
Private Sub Form_Load()
Dim ClassName As String: ClassName = Space$(256) Dim ret As Long: ret = GetClassName(Me.hwnd, ClassName, 256) If Left$(ClassName, ret) = "ThunderFormDC" Then MsgBox "Esta aplicacion debe correr compilada", , "" End End If Me.BackColor = vbBlack: Me.ForeColor = vbWhite: Me.FontBold = True Me.Top = 0: Me.Left = 0: Me.Width = 6450: Me.Height = 1000 Me.BorderStyle = 5: Timer1.Interval = 16
End Sub
Private Sub Timer1_Timer() Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1) Dim Cor As POINTAPI: Dim retorno As Long: retorno = GetCursorPos(Cor) Dim Handle As Long: Handle = WindowFromPoint(Cor.x, Cor.y) Dim idProc As Long: Call GetWindowThreadProcessId(Handle, idProc) Dim Handle_Proceso As Long: Handle_Proceso = OpenProcess(&H400 + &H10, 0, idProc) Dim Buffer As String: Buffer = Space$(255) Dim ret As Long: ret = GetModuleFileNameExA(Handle_Proceso, 0, Buffer, 255) Dim Ruta As String: Ruta = Left$(Buffer, ret): Call CloseHandle(Handle_Proceso) Me.Cls: Me.Print "": Me.Print Ruta: Me.Caption = "ID PROCESO = " & idProc
End Sub
|
|
|
En línea
|
Adrian Desanti
|
|
|
seba123neo
|
esta buena la idea  , lo unico que no me gusta es el tema ese de programar en una linea, la verdad casi no se puede leer el codigo. saludos.
|
|
|
En línea
|
|
|
|
Dessa
Desconectado
Mensajes: 624
|
Si, es una de mis tantas malas costumbres 
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long 'Dessa Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwprocessid As Long) As Long Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function GetModuleFileNameExA Lib "PSAPI.DLL" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Type POINTAPI: x As Long: y As Long: End Type
Dim CtlHandle As Long
Private Sub Form_Load() Me.BackColor = vbBlack Me.ForeColor = vbWhite Me.FontBold = True Me.Top = 0: Me.Left = 0 Me.Width = 6450 Me.Height = 1000 Me.BorderStyle = 5 Timer1.Interval = 16
End Sub
Private Sub Timer1_Timer() Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, &H2 Or &H1) Dim Cor As POINTAPI Call GetCursorPos(Cor) Dim Handle As Long Handle = WindowFromPoint(Cor.x, Cor.y) If Handle <> CtlHandle Then
Dim idProc As Long Call GetWindowThreadProcessId(Handle, idProc) Dim Handle_Proceso As Long Handle_Proceso = OpenProcess(&H400 + &H10, 0, idProc) Dim Buffer As String Buffer = Space$(255) Dim ret As Long ret = GetModuleFileNameExA(Handle_Proceso, 0, Buffer, 255) Dim Ruta As String Ruta = Left$(Buffer, ret) Call CloseHandle(Handle_Proceso) Me.Cls Me.Print "" Me.Print Ruta Me.Caption = "PID = " & idProc CtlHandle = Handle
End If
End Sub
|
|
« Última modificación: 28 Enero 2010, 21:17 pm por Dessa »
|
En línea
|
Adrian Desanti
|
|
|
|
Mensajes similares |
|
Asunto |
Iniciado por |
Respuestas |
Vistas |
Último mensaje |
|
|
problema con app.path
Programación Visual Basic
|
maxtextla
|
9
|
4,470
|
5 Octubre 2011, 00:38 am
por 79137913
|
|
|
Path of exile
Juegos y Consolas
|
marc20
|
0
|
3,256
|
27 Septiembre 2013, 11:25 am
por marc20
|
|
|
IIS Physical Path?
Hacking
|
cachuchin
|
0
|
2,409
|
12 Mayo 2020, 03:03 am
por cachuchin
|
|
|
Red Team Tools Path
Tutoriales - Documentación
|
ehn@
|
0
|
1,044
|
16 Noviembre 2023, 16:49 pm
por ehn@
|
|
|
PenTesting Path
Tutoriales - Documentación
|
ehn@
|
0
|
1,708
|
17 Noviembre 2023, 17:47 pm
por ehn@
|
|