home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Tools / ApiHooks 2.2 / examples / VB / AUTOHOOK / AutoHook.bas < prev    next >
Encoding:
BASIC Source File  |  2000-04-09  |  1.5 KB  |  45 lines

  1. Attribute VB_Name = "MainModule"
  2. Option Explicit
  3.  
  4. Public Declare Function GetCurrentProcessId Lib "KERNEL32.dll" _
  5.     () As Long
  6.  
  7. Public Declare Function GetVersion Lib "KERNEL32.dll" _
  8.     () As Long
  9.     
  10. Public Declare Function GetModuleHandle Lib "KERNEL32.dll" _
  11.     Alias "GetModuleHandleA" (ByVal Module As Any) As Long
  12.     
  13. Public AddrContents(2) As ADDRESS_CONTENTS
  14. Public ApiUnhook As API_UNHOOK
  15. Function GetFuncAddr(lpFuncAddr As Long) As Long
  16.  GetFuncAddr = lpFuncAddr
  17. End Function
  18. Function NewGetVersion() As Long
  19.  NewGetVersion = 9
  20. End Function
  21. Sub Main()
  22.  If LoadAndCall("Alien.dll", GetCurrentProcessId(), 1, 0&) <> 0 Then
  23.   MsgBox "Module Alien.dll loaded!", vbOKOnly, "AH in VB"
  24.  Else
  25.   MsgBox "Module Alien.dll not loaded!", vbOKOnly, "AH in VB"
  26.  End If
  27.  
  28.  MsgBox "KERNEL32.dll loaded at " + Hex(IsModuleLoaded("kernel32.dll", GetCurrentProcessId())), _
  29.        vbOKOnly, "AH in VB"
  30.  
  31.  If HookApi("kernel32.dll", "GetVersion", HOOK_ALL, ALL_MODULES, 0&, GetFuncAddr(AddressOf NewGetVersion), 0&) = ErrorSuccess Then
  32.   MsgBox "API GetVersion hooked!", vbOKOnly, "AH in VB"
  33.  Else
  34.   MsgBox "API GetVersion not hooked!", vbOKOnly, "AH in VB"
  35.  End If
  36.  
  37.  If UnloadModule("Alien.dll", GetCurrentProcessId(), 10) = 0 Then
  38.   MsgBox "Module Alien.dll unloaded!", vbOKOnly, "AH in VB"
  39.  Else
  40.   MsgBox "Module Alien.dll not unloaded!", vbOKOnly, "AH in VB"
  41.  End If
  42.  
  43.   MsgBox "OS Version = " + Str(GetVersion() And 15), vbOKOnly, "AH in VB"
  44. End Sub
  45.