Loading 16 bits dll (ICL icon library file)

M

MsNews

Hi,

I'm creating a free Icon library in C# with source code include, it already
support .ico/.dll../exe and I'd like to support .ICL format too, I need to
load a file .ICL (Icon Library) that basically it is a 16-bit dll and then
after that I can extracts and insert icons inside.

I tried the only function in Win32API left for 16bit (LoadModule), it loads
the library but Windows starts to give strange message boxes, as "Not enough
memory to run 16-bit applications" or things like that.

So, do you know a way to load 16bit dll (New Executable format) in Win32? Or
how to read/write .ICL files?
Any kind of information RFC/Articles/News everything related to ICL file can
be useful and will be apreciated.

Thanks a lot.
Gustavo.
 
C

Chris Becke

You know, I was under the impression that Win32 apps could load 16bit
resource dlls by calling LoadLibraryEx with the LOAD_LIBRARY_AS_DATAFILE
flag.
 
N

news.microsoft.com

When I tried that, the library (ICL) did not load and it gives, the
following error on GetLastError();

193 - ERROR_BAD_EXE_FORMAT (Is not a valid application.)

Then to make sure was not because of the ICL, I uncompress a Win3.1
installation and I tried to load some dlls as PBRUSH.DLL and I got the same
result.

So, I don't know what else to use to load this kind of resources.

Gustavo.
 
T

Tim Roberts

news.microsoft.com said:
When I tried that, the library (ICL) did not load and it gives, the
following error on GetLastError();

193 - ERROR_BAD_EXE_FORMAT (Is not a valid application.)

Then to make sure was not because of the ICL, I uncompress a Win3.1
installation and I tried to load some dlls as PBRUSH.DLL and I got the same
result.

So, I don't know what else to use to load this kind of resources.

The NE file format is not really very complicated. Just open the file
using the standard file APIs and read it yourself. There must still be a
bunch of NE resources on the web.
 
N

news.microsoft.com

I was reading this excellent article about NE

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q65122

Doesn't look too complicate, the problem is if I open and process the file I
won't get a valid Windows Handle, and will not be able to use the APIs like

LoadResource, FindResource, BeginUpdateResource, LoadIcon, etc.

I was reading that those APIs works under 32 and 16 bits, the problem is how
to get a handle to the module.

If I don't load the NE in the way Windows does, then I will have to
implement all those APIs myself, that means also I have to know and parse
the Resources format too inside the NE.

If I can get a 16bits load in memory as a DataFile and get a HMODULE handle
to it, the rest should be piece of cake using standards Windows APIs

Gustavo.
 
B

Ben Voigt

news.microsoft.com said:
I was reading this excellent article about NE

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q65122

Doesn't look too complicate, the problem is if I open and process the file
I won't get a valid Windows Handle, and will not be able to use the APIs
like

LoadResource, FindResource, BeginUpdateResource, LoadIcon, etc.

By parsing the file yourself, you would need to write your own LoadResource
function, however after reading the raw data into memory you can still use
for example CreateIconFromResource for all the image manipulation.

All the functions that work on HMODULEs are designed for PE-format
executables.
I was reading that those APIs works under 32 and 16 bits, the problem is
how to get a handle to the module.

The file doesn't contain a PE module.
If I don't load the NE in the way Windows does, then I will have to
implement all those APIs myself, that means also I have to know and parse
the Resources format too inside the NE.

The way Windows loads 16-bit programs is through wowexec. You can probably
use its APIs. See http://www.microsoft.com/msj/0898/hood0898.aspx
If I can get a 16bits load in memory as a DataFile and get a HMODULE
handle to it, the rest should be piece of cake using standards Windows
APIs

Gustavo.
 
N

news.microsoft.com

Thanks for the info... I keep researching on the article you sent me.

I just wanted to create a .ico file and now I'm swimming in deep waters to
understand MZ files and how to parse obsolete executables....

How I came here :)... the worst think is that the curiosity doesn't let me
go back to the library, I'm not interested in continue or publish it without
first at least know how to parse an ICL file.

Gustavo.

Ben Voigt said:
news.microsoft.com said:
I was reading this excellent article about NE

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q65122

Doesn't look too complicate, the problem is if I open and process the
file I won't get a valid Windows Handle, and will not be able to use the
APIs like

LoadResource, FindResource, BeginUpdateResource, LoadIcon, etc.

By parsing the file yourself, you would need to write your own
LoadResource function, however after reading the raw data into memory you
can still use for example CreateIconFromResource for all the image
manipulation.

All the functions that work on HMODULEs are designed for PE-format
executables.
I was reading that those APIs works under 32 and 16 bits, the problem is
how to get a handle to the module.

The file doesn't contain a PE module.
If I don't load the NE in the way Windows does, then I will have to
implement all those APIs myself, that means also I have to know and parse
the Resources format too inside the NE.

The way Windows loads 16-bit programs is through wowexec. You can
probably use its APIs. See
http://www.microsoft.com/msj/0898/hood0898.aspx
 
B

Ben Voigt

news.microsoft.com said:
Thanks for the info... I keep researching on the article you sent me.

I just wanted to create a .ico file

You could just write a 16-bit helper program that opens the dll, extracts
all the icons into standard format .ico files, then use those from your main
program.
 
N

news.microsoft.com

Yes, but the idea is to full support ICL files, means read/write 16-bit
dlls. (simple dlls without code/data just resource table)

If I can extract the icons from the ICL is one big step, but still it is not
useful, because provide an application/library to open/read ICL (Icon
libraries) without able to change it, doesn't worth too much.
 
A

Andy Bates

Hi -

Take a look at:

http://benoit.papillault.free.fr/c/disc2/exefmt.txt
http://www.itee.uq.edu.au/~csmweb/decompilation/new_exe.html

They appear to document the MZ/NE executable format.

1. Open a binary file to the executable/dll.
2. Find the NE header by looking at the MZ header.
3. Locate the resource table segment in the NE header.
4. You should then be able to iterate over the resources one by one.

Haven't completed any work like that for a while and certainly not in .NET
but it should be fairly trivial once you get into it.

Looking in the Platform SDK in WINNT.H; if you search for MZ below that it
defines the structures referenced in the above documents.

HTH

- Andy
 
C

Cyril Gupta

Hello Gustavo,

I read your article. Much impressed!

Regards,
Cyril Gupta
- You can do anything with a little bit of 'magination.

- I've been programming so long, my brain is now soft-ware.

M> Yep,
M>
M> Those kind of source is exactly what I used to read/write ICL files.
M>
M> Take a look at the article I wrote about Icons.
M>
M> http://www.codeproject.com/useritems/IconLib.asp
M>
M> Regards,
M> Gustavo.
M> M>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top