FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
SetWindowsHookEx
Hola, como están.
Estoy intentado hacer un hook al mouse tengo una dll con el siguiente code.
Esta dll si la cargo normal funciona bien, pero por el contrario si la inyecto en un proceso no me funciona. La inyección se realiza por que lo he comprobado por medio de un messagebox, he leido que SetwindowsHookex no funciona desde una dll inyectada. alguien a tenido el mismo problema. Última edición por angelp4492 fecha: 09-01-2017 a las 18:44:16. |
#2
|
||||
|
||||
Si se puede inyectar la dll y funcionará. El hook sólo funciona en el contexto del thread que hace la llamada a SetWindowsHookEx. El problema es que si inyectas con CreateRemoteThread para provocar un LoarLibrary en un proceso remoto, el thread creado termina tras la inyección y por eso dejará de funcionar el hook al mouse.
La solución es crear un nuevo Thread que se mantenga en el proceso inyectado y listo:
Este problema no aparece si realizas la técnica de inyección por suspensión de thread, más compleja y que requiere inyección directa. Ten en cuenta que si tu S.O. es de 64bits, no puedes inyectar una dll 32bits en procesos 64bits. Para eso debes compilar tu dll y tu inyector a 64bits. Saludos. |
#3
|
|||
|
|||
Gracias escafandra, lo pruebo en cuanto llegue a casa. Precisamente estoy siguiendo un tutorial tuyo sobre Api_hook espectacular por cierto.
la técnica que utizo para la inyección es como tu bien dices CreateremoteThread (seguro que alguna función publicada por tí), voy a buscar la técnica que me indicas de suspender el thread. Tengo un poco de lio con la inyección en 64 bit y de 32 bit. a ver yo tengo un pc con windows 7 de 64 bits y hay procesos que corren en 32 bits (firefox.exe *32) por ejemplo y otros en 64 bits. con esta inyección me funciona en un pc con windows 7 32 bit, pero no me funciona en windows 7 64 bits en proceso de 32 bits. (ni compilando la dll y el injector en el pc de 64 bits, CreateremoteThread me devuelve 0 y sale).
Última edición por angelp4492 fecha: 10-01-2017 a las 13:42:23. |
#4
|
||||
|
||||
Seguramente tendrás que crearla compilando 64 bits, con las versiones nuevas de delphi, o con lazarus.
|
#5
|
||||
|
||||
Reglas básicas:
1. No puedes inyectar código 32 bits en un proceso de 64bits 2. No puedes inyectar código 64bits en un proceso de 32bits. 3. Si puedes inyectar 32->32 y 64->64 4. Para inyectar en 32bits necesitas un inyector compilado a 32bits 5. Para inyectar 64bits necesitas un inyector compilado a 64bits. 6. Las dos últimas reglas pueden solucionarse teóricamente con técnicas complejas. Saludos. |
#6
|
||||
|
||||
Saludos. |
#7
|
||||
|
||||
Cita:
Inyección directa de código en C y en delphi Inyección directa de código II Saludos. |
#8
|
|||
|
|||
Funciono Perfecto. Gracias escafandra, voy a revisar los enlaces que me has puesto.
|
#9
|
|||
|
|||
Hola me surgió una nueva duda. ahora que todo va bien con la inyección y el hook al mouse, intento capturar el titulo de la ventana activa al pulsar un boton pero no me sale. Lo he intentado con GetwindowsText pero en la MSDN dice que si estamos en otro proceso utilizar SendMessage con WM_GETTEXT.
este es el codigo en condiciones normales si funciona.
que estoy haciendo mal, donde se me ha perdido el handle Última edición por angelp4492 fecha: 11-01-2017 a las 19:05:00. |
#10
|
||||
|
||||
Saludos. |
#11
|
|||
|
|||
Gracias, escafandra casi lo tenia
|
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Sobre SetWindowsHookEx | dec | Trucos | 0 | 01-07-2006 00:31:30 |
|