views:

250

answers:

4

My windows co-workers were asking me if I could modify my non-windows binary files such that when their "Properties" are examined under Windows, they could see a "Version" tab like that which would show for a Visual Studio compiled exe.

Specifically, I have some gzipped binary files and was wondering if I could modify them to satisfy this demand. If there's a better way, that would be fine, too.

Is there a way I could make my binaries appear to be exe files?

I tried simply appending the VS_VERSION_INFO block from notepad.exe to the end of one of my binaries in the hope that Windows scans for the block, but it didn't work.

I tried editing the other information regarding Author, Subject, Revision, etc. That doesn't modify the file, it just creates another data fork(what's the windows term?) for the file in NTFS.

A: 

Can't think of any way to do this short of a shell extension. The approach I've taken in the past is a separate "census" program that knows how to read version information from any kind of file.

Zip files can be converted into exe files by using a program that turns a zip file into a self-extracting zip (I know that WinZip does this, there are most likely free utilities for this also; here's one that came up on a search but I haven't actually tried it). Once you've got an exe, you should be able to use a tool like Resource Hacker to change the version information.

jdigital
The only part of my file that can be modified is the end. It's a Linux kernel and ramdisk. And I've already written my own little program which adds a keyed 1024 block to the ends of these files. The contents of the block are up to the user.
Harvey
A standalone utility might be your best bet. You can make it easy to use such a utility from the explorer by (1) adding a right click action that will work on all files (e.g., "See Version Info with Harvey's Viewer"), and (2) supporting drag and drop so that you can drag a file from the explorer to the app.
jdigital
I ended up writing a little shell script utility (for the Linux side) that will append/modify/remove a custom 1k block that the user can fill with anything they desire.
Harvey
A: 

It won't work. Either Windows would have to know every file format or no file format would be disturbed if version information were appended to it.

Dingo
Well, I was hoping that it might work like an ID3 tag in an MP3 file does. It doesn't matter where the TAG resides.
Harvey
ID3 tag is specific to MP3
Shay Erlichmen
That's why he said "like", as in, "similarly to".
Joe
A: 

No, resource section is only expected inside PE (portable executable; exe, dll, sys).
It is more then just putting the data inside the file, you have a table that points to the data in the file header.

What you can do if you have NTFS drive, is to use NTFS stream to store custom properties this way the contact of the binary file will remain the same, but you will need to use a custom shell extension to show the content of the stream.

Shay Erlichmen
The PE/COFF pointer is helpful. I'm thinking about whether the stream approach will work for me. These two files are built in an ext2 filesystem but they eventually are copied and live in an ntfs partition.
Harvey
+1  A: 

It is not supported by windows, since each file type has their own file format. But that doesn't mean you can't accomplish it. The resources stored inside dlls and exes are part of the file format.

Display to the user:

If you wanted this information to be displayed to the user, this would probably be best accomplished with using a property page shell extension. You would create a similar looking page, but it wouldn't be using the exact same page. There is a really good multi part tutorial on shell extensions, including property pages starting with that link.

Where to actually store the resource:

Instead of appending a block to the file, you could store the resource into a separate alternate data stream on the same file. This would leave the original file stream non corrupted on disk and not cause its primary file size to change.

Alternate data streams allow more than one data stream to be associated with a filename. Each stream is identified by a colon : at the end of the filename and an identifier.

You can create them for example by doing:

notepad test.txt:adsname1
notepad test.txt:adsname2
notepad test.txt

Getting the normal Win32 APIs working:

If you wanted the normal API to work, you'd have to intercept the Win32 APIs: LoadLibraryEx, FindResource, LoadResource and LockResource. This is probably not worth the trouble though since you are already creating your own property page.

Brian R. Bondy