News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

LoadLibrary/FreeLibrary

Started by chemicalNova, August 07, 2005, 05:07:37 PM

Previous topic - Next topic

chemicalNova

Howdy all,

I wanting to create a DLL which can be passed the name of an API, and for the DLL to fire it (with the given arguments). I know I need to use LoadLibrary, GetProcAddress and FreeLibrary, I just have no idea how to implement it. I'm wanting to do this so I can use it in Visual Basic, because using the API in visual basic doesn't seem to be working for me, to get what I want achieved. For example, calling the function from VB:

DoAPI "user32","SetWindowTextA",hWnd,"Title", ByVal 0&, ByVal 0&

Would this be possible? Is anyone able to point me in the right direction?

TIA

chem

comrade

Yes, I have made a program similar to what you are asking. You can view the source and encapsulate a similar logic for your purposes.

This program can be called from command-line as follows:

dllcall.exe user32 MessageBoxA 0 s:Title "s:Hello World!" 0


The first parameter is the name of thr DLL. The seconnd is the name of the procedure. All the others are parameters (remember to put them in reverse order for stdcall!).



[attachment deleted by admin]

chemicalNova

Hey thanks for that comrade  :U

I'm still extremely new to MASM, and I have no idea how I would change that into a procedure. I need this so I can get a return value aswell. I eventually want to be able to call any API, and store it in a variable in Visual Basic, hence the need for a return value.

Is it possible to turn that into a procedure? Sorry if its a bother :S

chem

comrade

I am not sure you can have multiple function arguments in Visual Basic. I think it only supports STDCALL. It may be possible to create a ParamArray implementation of DoAPI(), but that would have to have an additional C++ COM server. In other words, a lot of hassle.

I suggest you ask this question in #visualbasic on EFnet. Users like OnErr0r and llama (cynica_l) have done combination of assembly and Visual Basic, so they might help you out there.

PBrennick

The GeneSys Project is available from:
The Repository or My crappy website