Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: cobein en 8 Octubre 2008, 01:32 am



Título: GetProcAddress alternative function
Publicado por: cobein en 8 Octubre 2008, 01:32 am
Código:
'---------------------------------------------------------------------------------------
' Module      : mGetProcAddress
' DateTime    : 06/10/2008 20:06
' Author      : Cobein
' Mail        : cobein27@hotmail.com
' WebPage     : http://www.advancevb.com.ar
' Member of   : http://hackhound.org/
' Purpose     : GetProcAddress alternative function
' Usage       : At your own risk
' Requirements: None
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce
'               or publish this code on any web site,
'               online service, or distribute as source
'               on any media without express permission.
'
' Reference   : Based on ExtremeCoder sample [http://www.rohitab.com/discuss/lofiversion/index.php/t30773.html]
'
' History     : 06/10/2008 First Cut....................................................
'               06/10/2008 Minor change in buffer size to increase speed................
'---------------------------------------------------------------------------------------
Option Explicit

Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpLibFileName As String) As Long
Private Declare Sub GetMem4 Lib "msvbvm60" (ByVal Addr As Long, RetVal As Long)
Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long
Private Declare Function SysAllocString Lib "oleaut32.dll" (ByVal pOlechar As Long) As String

Public Function GetProcAddressAlt(ByVal sLib As String, ByVal sMod As String) As Long
    Dim lLib    As Long
    Dim i       As Long
   
    lLib = LoadLibraryA(sLib)
   
    If Not lLib = 0 Then
        Dim dwNumberOfNames As Long
        Dim dwNamesOffset   As Long
        Dim dwNameRVAs      As Long
        Dim dwFuncOffset    As Long
        Dim dwFuncRVAs      As Long
   
        GetMem4 (lLib + &H3C), i
        GetMem4 (lLib + i + &H78), i
   
        GetMem4 (lLib + i + &H18), dwNumberOfNames
        GetMem4 (lLib + i + &H20), dwNamesOffset
        GetMem4 (lLib + i + &H1C), dwFuncOffset

        Dim sBuff   As String * 128
        Dim sName   As String

        For i = 0 To dwNumberOfNames - 1
            GetMem4 (lLib + dwNamesOffset + i * &H4), dwNameRVAs
            GetMem4 (lLib + dwFuncOffset + i * &H4), dwFuncRVAs

            sBuff = SysAllocString(lLib + dwNameRVAs)
            sName = Left$(sBuff, lstrlen(sBuff))
           
            If sName = sMod Then
                GetProcAddressAlt = lLib + dwFuncRVAs
                Exit Function
            End If
        Next
    End If
   
End Function


Título: Re: GetProcAddress alternative function
Publicado por: el_c0c0 en 8 Octubre 2008, 04:52 am
tambien se pueden sacar otros nombres de procedimientos no? por lo que vi haces un for y si el procedimiento q buscas es igual al item del array entonces es ese..
no?

saludos


Título: Re: GetProcAddress alternative function
Publicado por: cobein en 9 Octubre 2008, 00:24 am
Exactamente, podes listar todas las funciones exportadas de la libreria.