File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Extract DLL version in Java/Linux environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Extract DLL version in Java/Linux environment" Watch "Extract DLL version in Java/Linux environment" New topic

Extract DLL version in Java/Linux environment

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

Does anyone know a technique for retrieving the version of a DLL file in Java? I'm willing to consider solutions that drop to command line to execute an external program, although it needs to run on a Linux (no Windows!) environment.

I'm also wondering if it's possible to extract the version from reading the raw DLL bytes into an array, but I have not seen a DLL byte diagram that might assist in doing so.

[OCA 8 Book] [Blog]
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

It's been some time since I've meddled with DLLs, and it is possible that the file format has been extended significantly. But it should still be documented on MSDN. Try to look for Portable Executable File Format, there is a page on MSDN and some other Google hits.

The PE/COFF format consists of blocks and it should be possible to traverse and process them. It's gonna be a messy stuff, though. Some inspiration could probably be gleaned from Wine, which naturally deals with Windows executables.

I believe there are no significant differences in the format between 16/32/64 bit versions of the DLLs, but I'm not sure.
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

Then there is PE/COFF 4J. Probably too embryonic to provide what you need, but might be a good starting point. Apparently it can process the basic structure of the DLL.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17421

"Microsoft PE and COFF Specification"

I see Martin found it as well.

Linux doesn't use DLL or MS executable binary file formats itself. You'd either have to install Wine or scan the file. I used to have some C code to parse DLLs, but that was so long ago that DLLs weren't versionable, and I don't even know where the code is anymore (probably on a floppy).

Speaking of Wine, you might want to do a quick perusal of its source code and see if there's something you can hijack.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Extract DLL version in Java/Linux environment
It's not a secret anymore!