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.
Categories: Code
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, 0Try using the proper library “shell32.dll”
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
You have to pass the pointer to the structure, not the structure itself like varptr(udt)