Calling Pointers in VB6
Option Explicit
Private Type SUBROUTINE
lNull As Long '// Must be 0
lPtr As Long
End Type
Private Declare Function GoSubReturn Lib "MSVBVM60" Alias "__vbaGosubReturn" (ByRef lpSubRoutine As Long) As Long
'---------------------------------------------------------------------------------------
' Procedure : GoToPtr
' Author : Karcrack
' Date : 08/05/2010
' Purpose : GoTo a pointer
' Warning : It's not a JMP, is a GoTo, so the execution of the program won't continue
' where you made the GoTo...
'---------------------------------------------------------------------------------------
'
Public Sub GoToPtr(ByVal lPtr As Long)
Dim tSubRoutine As SUBROUTINE
tSubRoutine.lPtr = lPtr
Call GoSubReturn(VarPtr(tSubRoutine))
End Sub
Due some problems with Stack you won’t be able to return the place you call this function… So generally you will need to close process in the code pointed by lPtr :)
Example:
Sub Main()
Call GoToPtr(gP(AddressOf RMain))
End Sub
Function gP(ByVal lPtr As Long) As Long
gP = lPtr
End Function
Sub RMain()
MsgBox "Hi!"
End
End Sub
Categories: Code
Really good source, Ive been looking for a way to do this without the classic stuff, callwindowproc or vtable patch and this looks really good. Great work!
thanks This i verry Good stuff
Awesome, i wll use this in one packer.