Home > Code > Invoke – CallAPIByName

Invoke – CallAPIByName

This project was really complex to me, it took me a lot of time of reasearch test and debug but finally (I hope so) is done and working pretty stable. This is a CallAPIByName using only RtlMoveMemory to load libraries, GetProcAddress an do the calls.

The project covers a lot of different code techniques to accomplish the main purpose, avoid as many APIs as possible.

Invoke

Categories: Code
  1. June 25th, 2009 at 07:30 | #1

    That’s good .. but don’t work with ShellExecute, i don’t get any error but file don’t run

    Dim inv     As New cInvoke
    Dim lLib    As Long
    Dim lMod    As Long
    lLib = inv .LoadLibrary("kernel32")
    lMod = inv .GetProcAddress(lLib, "ShellExecuteW")
    inv .Invoke lMod, 0, 0, StrPtr("c:\test.exe"), 0, 0
  2. admin
    June 25th, 2009 at 15:31 | #2

    Try using the proper library “shell32.dll”

  3. M. Lafleur
    March 27th, 2010 at 02:20 | #3

    I have a little problem when making some calls:
    I am trying to make call an API wich takes a UDT as argument and i am getting this error

    "Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions"

    the declaration is

    'Private Declare Function CryptUnprotectData Lib "crypt32" (ByRef pDataIn As DATA_BLOB, ByVal ppszDataDescr As Long, ByVal pOptionalEntropy As Long, ByVal pvReserved As Long, ByVal pPromptStruct As Long, ByVal dwFlags As Long, ByRef pDataOut As DATA_BLOB) As Long

    i tried to make the call like this
    Public Function CryptUnprotectData(ByRef pDataIn As DATA_BLOB, ByVal ppszDataDescr As Long, ByVal pOptionalEntropy As Long, ByVal pvReserved As Long, ByVal pPromptStruct As Long, ByVal dwFlags As Long, ByRef pDataOut As DATA_BLOB) As Long

    With rPe
    If .Initialized Then
    lMod = .GMd("crypt32", "CryptUnprotectData")
    CryptUnprotectData = .hC(lMod, pDataIn, ppszDataDescr, pOptionalEntropy, pvReserved, pPromptStruct, dwFlags, pDataOut)
    End If
    End With

    End Function

    the UDT is

    Public Type DATA_BLOB
    cbData As Long
    pbData As Long
    End Type

    i tried to place the UDT declaration in a public module , declaring the invoke function as freind instead of public but this didn't help

    i googled it more than four hours :(

    i know i will find the answer here:)

    Thanks in advance

  4. March 29th, 2010 at 19:05 | #4

    You have to pass the pointer to the structure, not the structure itself like varptr(udt)

  1. No trackbacks yet.
You must be logged in to post a comment.