elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a la Factorización De Semiprimos (RSA)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  [SNIPPET] mPatchFunction - Parchea funciones para hacer un jump a una nueva dir.
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [SNIPPET] mPatchFunction - Parchea funciones para hacer un jump a una nueva dir.  (Leído 1,393 veces)
Karcrack


Desconectado Desconectado

Mensajes: 2.416


Se siente observado ¬¬'


Ver Perfil
[SNIPPET] mPatchFunction - Parchea funciones para hacer un jump a una nueva dir.
« en: 30 Diciembre 2011, 12:51 pm »

Código
  1. Option Explicit
  2.  
  3. '---------------------------------------------------------------------------------------
  4. ' Module    : mPatchFunction
  5. ' Author    : Karcrack
  6. ' Date      : 27/11/2011
  7. ' Purpose   : Patch function with JMP to new addr
  8. '---------------------------------------------------------------------------------------
  9.  
  10. 'NTDLL
  11. Private Declare Function NtWriteVirtualMemory Lib "NTDLL" (ByVal hProcess As Long, ByRef lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, ByRef lpNumberOfBytesWritten As Long) As Long
  12.  
  13. Private Const CURRENT_PROCESS = (-1)
  14.  
  15. Public Function PatchFunction(ByVal pFnc As Long, ByVal pNewFnc As Long, Optional ByVal hProc As Long = CURRENT_PROCESS) As Boolean
  16.    Dim cCode   As Currency
  17.  
  18.    cCode = &HB8& * (0.0001@)                   'mov EAX, imm32
  19.    cCode = cCode + (pNewFnc * 0.0256@)         'imm32
  20.    cCode = cCode + (&HE0FF& * 109951162.7776@) 'jmp EAX
  21.  
  22.    PatchFunction = NtWriteVirtualMemory(hProc, ByVal pFnc&, cCode, &H8, 0&)
  23. End Function

Ejemplo de uso:
Código
  1. Sub Main()
  2.    Dim pMessageBoxW    As Long
  3.  
  4.    pMessageBoxW = GetProcAddress(LoadLibrary("USER32"), "MessageBoxW")
  5.  
  6.    If PatchFunction(AddressOf MessageBoxW__, pMessageBoxW) Then
  7.        If MessageBoxW__(0, "Did you like the function?", "Karcrack", vbYesNo) = vbYes Then
  8.            Call MessageBoxW__(0, "Glad you liked it", "Karcrack", 0)
  9.        Else
  10.            Call MessageBoxW__(0, "F**k you bastard xD", "Karcrack", 0)
  11.        End If
  12.    End If
  13. End Sub
  14.  
  15. Public Function MessageBoxW__(ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
  16.    'JMP &MessageBoxW@USER32
  17. End Function


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Tengo que hacer un practico de c++ FUNCIONES
Programación C/C++
JuakFull 3 7,515 Último mensaje 14 Junio 2011, 23:01 pm
por Don Pollo
Google parchea un fallo crítico en Chrome para Windows
Noticias
Slava_TZD 0 2,030 Último mensaje 25 Agosto 2011, 08:27 am
por Slava_TZD
Me pueden guiar para hacer Overclock a mi nueva PC
Hardware
cpichi.cu 0 2,927 Último mensaje 8 Septiembre 2011, 21:57 pm
por cpichi.cu
Hacer dos comprobaciones en un WHILE con funciones
Programación C/C++
RGT 3 1,731 Último mensaje 5 Noviembre 2015, 16:01 pm
por class_OpenGL
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines