resource-only dll

B

Bonj

when creating a resource-only dll, the only way I can get it to compile and
work correctly, is to make it a non-resource-only dll.
surely this can't be the way...?
basically, there is a load of resources, in a dll. The DLL is a managed
class library, but it has got an unmanaged function that accesses the
resources. FindResource only works on the HMODULE that is gained by casting
the HINSTANCE passed to DllMain into an HMODULE (I think they're the same
thing anyway.)
There is also a manged class to be accessed from a C# application, this bit
works fine. But it is just the /NOENTRY option that is baffling me.
The return value of GetModuleHandle, doesn't work - as in, it can't find the
resources with this handle.
Apart from the DLL resources, the only things in the DLL are some C code
just to access the resources, and the managed class.
How can I make it a resource-only managed DLL with C code in it, if
compiling it with /NOENTRY means that DllMain doens't get called? (which it
doesn't.)
 
I

Igor Tandetnik

Bonj said:
when creating a resource-only dll, the only way I can get it to
compile and work correctly, is to make it a non-resource-only dll.
surely this can't be the way...?
basically, there is a load of resources, in a dll. The DLL is a
managed class library, but it has got an unmanaged function that
accesses the resources.

Then how is it a resource-only DLL? A resource-only DLL - surprise
here - only contains resources, but no code. Yours is not a resouce-only
DLL, obviously.
How can I make it a resource-only managed DLL with C code in it

"Resource-only DLL with code in it" is an oxymoron.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage
 
B

Bonj

so it *must* have an entry point, in order to get an HMODULE?

Igor Tandetnik said:
Bonj said:
when creating a resource-only dll, the only way I can get it to
compile and work correctly, is to make it a non-resource-only dll.
surely this can't be the way...?
basically, there is a load of resources, in a dll. The DLL is a
managed class library, but it has got an unmanaged function that
accesses the resources.

Then how is it a resource-only DLL? A resource-only DLL - surprise here -
only contains resources, but no code. Yours is not a resouce-only DLL,
obviously.
How can I make it a resource-only managed DLL with C code in it

"Resource-only DLL with code in it" is an oxymoron.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles Babbage
 
B

Bonj

No - hang on, it can be a resource-only DLL with code in it. That isn't
contradictory. Being a resource-only DLL, meaning that it has got the
'resource only DLL ' compiler option checked. Not that it hasn't got any
code in it. If you put the 'resource only DLL' option on (/NOENTRY) it still
compiles and works when it's got code in it. It's just it has no way (that I
know of...) of getting an HMODULE that can access the resources.... but my
reason for posting, perhaps I can get the HMODULE in the same way that a
'resource-only' DLL which truly hasn't got any code in it gets its
HMODULE....no?
The only reason I want to use the /NOENTRY is to get rid of a linker
warning, see
http://support.microsoft.com/default.aspx?scid=kb;en-us;814472


Igor Tandetnik said:
Bonj said:
when creating a resource-only dll, the only way I can get it to
compile and work correctly, is to make it a non-resource-only dll.
surely this can't be the way...?
basically, there is a load of resources, in a dll. The DLL is a
managed class library, but it has got an unmanaged function that
accesses the resources.

Then how is it a resource-only DLL? A resource-only DLL - surprise here -
only contains resources, but no code. Yours is not a resouce-only DLL,
obviously.
How can I make it a resource-only managed DLL with C code in it

"Resource-only DLL with code in it" is an oxymoron.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles Babbage
 
I

Igor Tandetnik

Bonj said:
No - hang on, it can be a resource-only DLL with code in it.

It cannot, by definition. A resource-only DLL has _resources_ _only_ -
that's why it's called resource-only in the first place. If it has code
as well as resources, it is _not_ resource-only, because it has code in
additon to resources. I don't know how I could possibly state it any
clearer.
That
isn't contradictory. Being a resource-only DLL, meaning that it has
got the 'resource only DLL ' compiler option checked.

This option only works properly when the DLL does not have any code in
it - in other words, when it is resource-only.
Not that it
hasn't got any code in it. If you put the 'resource only DLL' option
on (/NOENTRY) it still compiles and works

If it works, why are you here asking questions? Apparently, it does not
work all that well.

Also, if you are OK with having code in it, why do you insist on
/NOENTRY? The point of /NOENTRY with a resource-only DLL is to make it
smaller, by having the linker throw away the code segment. But you
cannot throw away the code segment, since you have code in the DLL. So
what again is the point of the exercise?
but my reason for posting, perhaps
I can get the HMODULE in the same way that a 'resource-only' DLL
which truly hasn't got any code in it gets its HMODULE....no?

A resource-only DLL that has no code does not get its own HMODULE -
there's no code in it to "get" anything. It's just a data file in a
certain format. The code (in some other EXE or DLL) that wishes to use
this data file obtains HMODULE by calling LoadLibraryEx with
LOAD_LIBRARY_AS_DATAFILE flag.
The only reason I want to use the /NOENTRY is to get rid of a linker
warning, see
http://support.microsoft.com/default.aspx?scid=kb;en-us;814472

Ah, that's a different question. I don't quite see how a mixed DLL is
supposed to obtain its own HMODULE, considering that it's not allowed to
implement DllMain. You may want to start another thread with this
question.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage
 
B

Bonj

If it works, why are you here asking questions? Apparently, it does not
work all that well.

Define "apparently ... does not work all that well" ?

If I go one route, I have got the linker telling me my application might not
run correctly, yet it does. If go another route, I have got you telling me
it might not run correctly, yet it does. It's also confusing how they don't
put up a message box saying 'Sorry, this DLL can't be resource only. The
wizard has detected some code.'
To be fair, I am more inclined to believe you, as you have got a sensible
argument whereas the linker hasn't. But it's still confusing.
Also, if you are OK with having code in it, why do you insist on /NOENTRY?
The point of /NOENTRY with a resource-only DLL is to make it smaller, by
having the linker throw away the code segment. But you cannot throw away
the code segment, since you have code in the DLL. So what again is the
point of the exercise?


A resource-only DLL that has no code does not get its own HMODULE -
there's no code in it to "get" anything. It's just a data file in a
certain format. The code (in some other EXE or DLL) that wishes to use
this data file obtains HMODULE by calling LoadLibraryEx with
LOAD_LIBRARY_AS_DATAFILE flag.


So an *actual* resource only DLL is just basically a flat binary file?
 
M

Mihai N.

A resource-only DLL that has no code does not get its own HMODULE -
there's no code in it to "get" anything. It's just a data file in a
certain format. The code (in some other EXE or DLL) that wishes to use
this data file obtains HMODULE by calling LoadLibraryEx with
LOAD_LIBRARY_AS_DATAFILE flag.

It is a (not so well) known problem with this.

See here (search for LOAD_LIBRARY_AS_DATAFILE)
http://www.microsoft.com/msj/0499/multilangunicode/multilangunicode.aspx

Basically, on Windows 95 (9x ?) the "resource only dll" aproach does not work
properly. This is why I would recomand to use another popular name
"satellite DLL," and add a dummy DLLMain (as also recomended by the article).

Ok, this seems to be no problem if you don't support Windows 95.
But, really, why not be 100% compatible, when the price is so low?

And the article is a great read, regardless the dll question :)
 
G

Guest

Ah! "Satellite DLL" could be what I am after... I'll take a look at the
article. I'm not planning on supporting Win95 anyway as it's virtually
extinct now and my application uses a .NET front end which won't run on Win95
anyway.
 
I

Igor Tandetnik

Bonj said:
Define "apparently ... does not work all that well" ?

It seems to me, based on the very fact that you had to ask a question in
the first place, that you are not completely satisfied with the
performance of your setup. Is that a clear enough explanation?
If I go one route, I have got the linker telling me my application
might not run correctly, yet it does. If go another route, I have
got you telling me it might not run correctly, yet it does.

The linker warns about a different, completely unrelated issue. Not
about your resource setup, but about a problem in .NET CLR whereby mixed
mode DLLs may sometimes lock up upon loading unless DllMain is disabled.
The reason is that, if DllMain is not disabled, it may end up running
managed code, and managed code may deadlock when run under a loader
lock. The KB article you quote, as well as the whitepaper referred to by
the KB, go into this problem in great detail.

Again, this has nothing to do with your DLL containing or not containing
resources. Trying to make it a resource-only DLL is a wild goose chase -
forget about it. This is not your problem, your problems lie elsewhere.
That's why I suggest you start a new thread with a more specific
question - since a mixed mode DLL has to disable DllMain, how should it
obtain its own HMODULE?
So an *actual* resource only DLL is just basically a flat binary file?

Basically, yes.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage
 

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