Help!

windows .dll files and linux

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> App Development RSS
Next:  gaim spell check  
Author Message
juicymixx
External


Since: Mar 22, 2007
Posts: 1



PostPosted: Thu Mar 22, 2007 9:53 am    Post subject: windows .dll files and linux
Archived from groups: comp>os>linux>development>apps (more info?)

hey everyone,

I'm currently using a program on windows which is really irritating
me. It consistes of an .exe file and several .dll files which
apparently do 'all the work'. I wanted to take the .dll files and,
using them, code up a version of this app for linux. The problem is
that I'm not sure of the ins and outs of the .dll files. Is there a
way to figure out the inputs and params of the functions in the .dll
files?

Thanks.
Back to top
Lew Pitcher
External


Since: Jul 05, 2006
Posts: 290



PostPosted: Thu Mar 22, 2007 10:03 am    Post subject: Re: windows .dll files and linux [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mar 22, 12:53 pm, "juicym...@mailinator.com"
<juicym....TakeThisOut@mailinator.com> wrote:
> hey everyone,
>
> I'm currently using a program on windows which is really irritating
> me. It consistes of an .exe file and several .dll files which
> apparently do 'all the work'. I wanted to take the .dll files and,
> using them, code up a version of this app for linux. The problem is
> that I'm not sure of the ins and outs of the .dll files. Is there a
> way to figure out the inputs and params of the functions in the .dll
> files?

Unfortunately, your best bet is to ask that question in a Microsoft
Windows newsgroup (one of the comp.os.ms-windows.* groups). The answer
will take a knowledge of the internals of Microsoft DLL creation,
which you are unlikely to find here.

One caveat, though. It is not a trivial task to call a Windows DLL
entrypoint from a Linux program. In fact, as Linux uses a different
format for shared object modules, and different facilities to load
them, you are going to have a bl**dy hard time accessing DLL
entrypoints from your Linux programs.

I'd suggest that you take a look at Wine (http://www.winehq.org/) to
see how they do it. You might be able to scarf a piece of code that
will mate your Linux ELF executable with your Windows COFF DLLs.

Luck be with you
--
Lew
Back to top
Paul Pluzhnikov
External


Since: Nov 07, 2004
Posts: 355



PostPosted: Thu Mar 22, 2007 6:31 pm    Post subject: Re: windows .dll files and linux [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Lew Pitcher" <lpitcher DeleteThis @sympatico.ca> writes:

> On Mar 22, 12:53 pm, "juicym...@mailinator.com"
> <juicym... DeleteThis @mailinator.com> wrote:
>>
>> I'm currently using a program on windows which is really irritating
>> me. It consistes of an .exe file and several .dll files which
>> apparently do 'all the work'. I wanted to take the .dll files and,
>> using them, code up a version of this app for linux.

What exacly do you mean by 'using .DLL files, code up a version
for Linux'?

Do you mean to use .DLLs on Linux (unmodified), or do you mean to
re-implement the whole app?

>> The problem is
>> that I'm not sure of the ins and outs of the .dll files. Is there a
>> way to figure out the inputs and params of the functions in the .dll
>> files?

Sure: it's called reverse engineering.

Obviously you don't need to do that IF you are going to re-implement
the functionality. If you want to "transplant" .DLLs to Linux,
you need to become *very* proficient with "how DLLs work".

Begin by studying "dumpbin /EXPORTS foo.dll", "dumpbin /IMPORTS app.exe",
then stepping through the application in a debugger (at the assembly
level).

> Unfortunately, your best bet is to ask that question in a Microsoft
> Windows newsgroup (one of the comp.os.ms-windows.* groups). The answer
> will take a knowledge of the internals of Microsoft DLL creation,
> which you are unlikely to find here.

Some of us are unfortunate enough to possess such knowledge, and
concentration of such knowledge here may be even higher than in
*ms-windows* groups.


> One caveat, though. It is not a trivial task to call a Windows DLL
> entrypoint from a Linux program. In fact, as Linux uses a different
> format for shared object modules, and different facilities to load
> them, you are going to have a bl**dy hard time accessing DLL
> entrypoints from your Linux programs.

Or even loading them into the process in the first place.

> Luck be with you

Also, be aware that it may actually be faster to rewrite the app from
scratch.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Back to top
Mikko Rauhala
External


Since: Jul 02, 2004
Posts: 19



PostPosted: Thu Mar 22, 2007 10:01 pm    Post subject: Re: windows .dll files and linux [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 22 Mar 2007 10:03:33 -0700, Lew Pitcher <lpitcher RemoveThis @sympatico.ca> wrote:
> I'd suggest that you take a look at Wine (http://www.winehq.org/) to
> see how they do it. You might be able to scarf a piece of code that
> will mate your Linux ELF executable with your Windows COFF DLLs.

Incidentally this has already been done in media players so that you
can use, on x86, binary Windows codecs for media playback. You may
find useful code in xine, and mplayer, and the gstreamer-pitfdll
plugin. (AFAIK these are all under GPL, though, and if you take code,
rather than ideas, as such and distribute it along with the closed
libraries, it would probably be a breach of the license. In-house use
shouldn't be affected. Wine itself is LGPL, which may be a bit more
lax here, though I shan't speculate further in this case.)

--
Mikko Rauhala - mjr RemoveThis @iki.fi - <URL: http://www.iki.fi/mjr/ >
Transhumanist - WTA member - <URL: http://transhumanism.org/ >
Singularitarian - SIAI supporter - <URL: http://singinst.org/ >
Back to top
jasen
External


Since: Oct 13, 2006
Posts: 227



PostPosted: Fri Mar 23, 2007 9:01 am    Post subject: Re: windows .dll files and linux [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2007-03-22, juicymixx.DeleteThis@mailinator.com <juicymixx.DeleteThis@mailinator.com> wrote:
>
> hey everyone,
>
> I'm currently using a program on windows which is really irritating
> me. It consistes of an .exe file and several .dll files which
> apparently do 'all the work'. I wanted to take the .dll files and,
> using them, code up a version of this app for linux. The problem is
> that I'm not sure of the ins and outs of the .dll files. Is there a
> way to figure out the inputs and params of the functions in the .dll
> files?

Install the mingw32-msvc binutils, there should be something in there that
can extract a list of the entry-points

I'm not sure what you need to have to do to run w32 dlls from
linux apps though, but I recall that the gimp guys sorted that
out for photoshop plugins. winelib maybe?





--

Bye.
Jasen
Back to top
llothar
External


Since: Jul 10, 2005
Posts: 24



PostPosted: Sun Mar 25, 2007 4:39 pm    Post subject: Re: windows .dll files and linux [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 22 Mrz., 08:53, "juicym...@mailinator.com"
<juicym....TakeThisOut@mailinator.com> wrote:
> hey everyone,
>
> I'm currently using a program on windows which is really irritating
> me. It consistes of an .exe file and several .dll files which
> apparently do 'all the work'. I wanted to take the .dll files and,
> using them, code up a version of this app for linux. The problem is
> that I'm not sure of the ins and outs of the .dll files. Is there a
> way to figure out the inputs and params of the functions in the .dll
> files?
>
> Thanks.

Normal DLL's don't have any information about parameter or types.
ActiveX DLL's have a type library.
Back to top
Wolfgang Draxinger
External


Since: Jun 01, 2004
Posts: 104



PostPosted: Mon Mar 26, 2007 2:00 pm    Post subject: Re: windows .dll files and linux [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

juicymixx RemoveThis @mailinator.com wrote:

>
> hey everyone,
>
> I'm currently using a program on windows which is really
> irritating me. It consistes of an .exe file and several .dll
> files which apparently do 'all the work'.

This is not uncommon, as it makes it easier to replace a module
of the program without having to replace all the other parts.
The executable is then merely a loader, that sticks the
libraries together.

Most bigger applications are organized that way.

> I wanted to take the .dll files and, using them, code up a
> version of this app for linux.

You seem not to understand, that a DLL is practically the same
like an executable, but without an entry point. This means, that
a DLL like a .EXE has dependencies on the system and chances are
high, that the DLL references parts of the Windows API which are
not avaliable in Linux - except you're having WINE installed,
which provides a Win32 like API.

If you're sure, that the DLLs are not making use of any OS
function (very unlikely) you could write some wrapper, that
loads the DLL and links it into your program. Either you may use
code of the WINE project, or you make your own PE loader/linker,
which is not such a hard task as it may sound like. However if
the DLL references anything not avaliable from the other DLLs or
stuff you're providing you're out of luck. Also be aware that
most DLLs exposed functions use the WINAPI aka Pascal calling
convention, i.e. the parameters are passed in order on the stack
(which means that they come out in reverse order in memory),
whereas the C calling convention is other way round.

> Is there a way to figure out the inputs and params of the
> functions in the .dll files?

No. A DLL is just executable code, together with some table
mapping identifiers/ordinal numbers to addresses in the
executable.

However some DLLs (mainly OCX/ActiveX components, but also some
propritary plugin DLLs) provide a special identifier that gives
access to structures describing the DLL's interface. For
OCX/ActiveX this is specified in the COM standard, with
propritary models you've to figure it out.

I should note, that none of the widespread shared library formats
has been designed to bring such information by default, but on
most *nix like systems the debug versions of .so contain DWARF
data which is practically such a information. But Windows DLLs
don't have this, sorry.


Wolfgang Draxinger
--
E-Mail address works, Jabber: hexarith RemoveThis @jabber.org, ICQ: 134682867
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> App Development All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum