Tool to get interface lib from dll (windows only)

User projects written in or related to FreeBASIC.
marpon
Posts: 342
Joined: Dec 28, 2012 13:31
Location: Paris - France

Tool to get interface lib from dll (windows only)

Postby marpon » Jun 11, 2015 16:16

Here is a link to tool https://dl.dropboxusercontent.com/u/104528350/Infos/Dll2a.rar

the freebasic sources generated from firefly (and adapted)
the needed tools to : generate DEF files , edit def-files , dlltool and as to create the lib file (.a)
and the resulting exe file

I decided to incorporate the needed tools into the exe resource to avoid risk of missing files.

The interest of this project was
- to use firefly with 2 windows and test how easy it is ( yes it is)
- a demo of including files into the exe resource ( adapting sources from this forum)

and the possibility to create specific dll.a files
exemple : for not incorporated functions in the libuser32.dll.a...... as messageboxtimeoutA

all done in few hours yesterday

if you want to compile your own , a .bat file is also in board , just check the path for your compiler

by marpon
marpon
Posts: 342
Joined: Dec 28, 2012 13:31
Location: Paris - France

Re: Tool to get interface lib from dll (windows only)

Postby marpon » Jun 11, 2015 16:43

new simplified version: see here https://db.tt/s6Oe75Mh

Still totally autonomous, does not need the freebasic tools As.exe or dlltool.exe
everything in bord.
Can produce the lib interface automatically (full) or choosing the needed procedures (deleting the not needed ) on the DEF file.

It produce same type of interfaces than the official ones. ( mangled )

usage example ( for adapted LibUser32_dll.a )

Code: Select all

Extern "Windows" Lib "User32_dll"

Declare Function MessageBoxTimeout alias "MessageBoxTimeoutA" (ByVal As Hwnd, _
                  ByVal As String, ByVal As String, ByVal As Uinteger, _
                  ByVal As Uinteger, ByVal As Uinteger ) As Integer

End Extern
MrSwiss
Posts: 3542
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Tool to get interface lib from dll (windows only)

Postby MrSwiss » Jun 12, 2015 15:32

@marpon,

nice tool ... but what I don't understand:
marpon wrote:It produce same type of interfaces than the official ones. ( mangled )

That is not exactly true, because the "official" a file is: lib"name".dll.a and yours is: lib"name"_dll.a
This means renaming of the generated file "every Time", not so nice IMO.

Secondly, if there is no "def" file at hand, whats the use of the Editor?

Thirdly, why not simply a USER choice of Editor (there are so many around). I personally like Notepad++ ...

Sorry to sound critical, but feedback is usually needed in order to improve things ...
marpon
Posts: 342
Joined: Dec 28, 2012 13:31
Location: Paris - France

Re: Tool to get interface lib from dll (windows only)

Postby marpon » Jun 15, 2015 17:31

@MrSwiss

thanks for your test and comments.

That is not exactly true, because the "official" a file is: lib"name".dll.a and yours is: lib"name"_dll.a


it is in purpose, to avoid the risk of mixing existing official lib files with your specific libs, not to recreate the official ones.

Secondly, if there is no "def" file at hand, whats the use of the Editor?


The editor is only needed to suppress export entries on the Def generated file to create your own lib interface, the def file is always generated! The interest of dll file is to export sub/function , if not what kind of dll it is?
as you noticed , by default the automatic mode (without editor) is selected.

why not simply a USER choice of Editor

it was my first idea , in fact it is implemented in the first version, but it is not as easy to use as it seems:
in fact if you open the def file with your selected editor , specialy with multi tab editors( for ex Notepad++ as you like)
it is tricky to know if the file has been simply closed, or still opened... and decide to continue, specially if the multi tab editor have other files opened . Because in fact they are not really opened , usally the editors only access to the file , put them in memory to work with and close imediatly, that means very complicated to detect the status.


So I've decided to simplify and verify only if the editor ( notepad or the embedded editor) have been closed after opening that Def file, this is safer and more simple.

But , the first version was provided with source code , you can adapt to your own choice : name , editor ...

if you do so , please post your adaptation.

Marpon

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 5 guests