The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: chemicalNova on August 07, 2005, 05:07:37 PM

Title: LoadLibrary/FreeLibrary
Post by: chemicalNova on August 07, 2005, 05:07:37 PM
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
Title: Re: LoadLibrary/FreeLibrary
Post by: comrade on August 07, 2005, 06:31:20 PM
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]
Title: Re: LoadLibrary/FreeLibrary
Post by: chemicalNova on August 07, 2005, 07:19:04 PM
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
Title: Re: LoadLibrary/FreeLibrary
Post by: comrade on August 07, 2005, 08:36:22 PM
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.
Title: Re: LoadLibrary/FreeLibrary
Post by: PBrennick on August 07, 2005, 11:27:00 PM
Hey comrade,

Cool tool!

Paul