From: Frederico Pissarra on
In a pure Win32 app, let's say hello.c, the generated code uses
CorExitProcess funcion from mscoree.dll to finalize the app....

Why?

[]s
Fred


From: Carl Daniel [VC++ MVP] on
Frederico Pissarra wrote:
> In a pure Win32 app, let's say hello.c, the generated code uses
> CorExitProcess funcion from mscoree.dll to finalize the app....
>
> Why?

Because you compiled it with /clr. A pure win32 app will not have any
reference to mscoree.dll. Make sure you've really got your project settings
set correctly.

-cd


From: Frederico Pissarra on

"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam(a)mvps.org.nospam>
wrote in message news:eH6TPCwXGHA.1196(a)TK2MSFTNGP03.phx.gbl...
> Frederico Pissarra wrote:
>> In a pure Win32 app, let's say hello.c, the generated code uses
>> CorExitProcess funcion from mscoree.dll to finalize the app....
>>
>> Why?
>
> Because you compiled it with /clr. A pure win32 app will not have any
> reference to mscoree.dll. Make sure you've really got your project
> settings set correctly.
>
> -cd
>

No... I don't compile with /clr... my compile command line was:

cl -Ox -GAF hello.c

even if I use -clr- (I don't know if this will turn /clr off!), the result
is the same!

Take a look at crt0dat.c in %msvcdir%/crt/src directory. There you can find
something like this:

------------%<--------------------------%<--------------------------
void __cdecl __crtCorExitProcess (
int status
)
{
HMODULE hmod;
PFN_EXIT_PROCESS pfn;

hmod = GetModuleHandle("mscoree.dll");
if (hmod != NULL) {
pfn = (PFN_EXIT_PROCESS)GetProcAddress(hmod, "CorExitProcess");
if (pfn != NULL) {
pfn(status);
}
}

/*
* Either mscoree.dll isn't loaded,
* or CorExitProcess isn't exported from mscoree.dll,
* or CorExitProcess returned (should never happen).
* Just call return.
*/
}

void __cdecl __crtExitProcess (
int status
)
{
__crtCorExitProcess(status);

/*
* Either mscoree.dll isn't loaded,
* or CorExitProcess isn't exported from mscoree.dll,
* or CorExitProcess returned (should never happen).
* Just call ExitProcess.
*/

ExitProcess(status);
}

------------%<--------------------------%<--------------------------

My question remains: Why to call CorExitProcess if my app is an Win32 App
(no .NET)?!?!

[]s
Fred



From: Jeff Partch [MVP] on
"Frederico Pissarra" <me(a)nowhere.net> wrote in message
news:O2VadPPYGHA.4484(a)TK2MSFTNGP02.phx.gbl...
> Take a look at crt0dat.c in %msvcdir%/crt/src directory. There you can
> find something like this:
>
> ------------%<--------------------------%<--------------------------
> void __cdecl __crtCorExitProcess (
> int status
> )
> {
> HMODULE hmod;
> PFN_EXIT_PROCESS pfn;
>
> hmod = GetModuleHandle("mscoree.dll");
> if (hmod != NULL) {
> pfn = (PFN_EXIT_PROCESS)GetProcAddress(hmod, "CorExitProcess");
> if (pfn != NULL) {
> pfn(status);
> }
> }
> My question remains: Why to call CorExitProcess if my app is an Win32 App
> (no .NET)?!?!
>


If all you're talking about is the above, then my take on it is that the CRT
only calls CorExitProcess if mscoree.dll is already loaded, or rather only
if it needs to.

--
Jeff Partch [VC++ MVP]


From: Frederico Pissarra on

"Jeff Partch [MVP]" <jeffp(a)mvps.org> wrote in message
news:eutP4VPYGHA.2148(a)TK2MSFTNGP02.phx.gbl...
> "Frederico Pissarra" <me(a)nowhere.net> wrote in message
> news:O2VadPPYGHA.4484(a)TK2MSFTNGP02.phx.gbl...
>> Take a look at crt0dat.c in %msvcdir%/crt/src directory. There you can
>> find something like this:
>>
>> ------------%<--------------------------%<--------------------------
>> void __cdecl __crtCorExitProcess (
>> int status
>> )
>> {
>> HMODULE hmod;
>> PFN_EXIT_PROCESS pfn;
>>
>> hmod = GetModuleHandle("mscoree.dll");
>> if (hmod != NULL) {
>> pfn = (PFN_EXIT_PROCESS)GetProcAddress(hmod,
>> "CorExitProcess");
>> if (pfn != NULL) {
>> pfn(status);
>> }
>> }
>> My question remains: Why to call CorExitProcess if my app is an Win32 App
>> (no .NET)?!?!
>>
>
>
> If all you're talking about is the above, then my take on it is that the
> CRT only calls CorExitProcess if mscoree.dll is already loaded, or rather
> only if it needs to.
>
> --
> Jeff Partch [VC++ MVP]
>

Jeff... I realize that... but why?! If I use anything from CLR I'll expect
to see my program checking if mscoree.dll is loaded and trying to call
CorExitProcess... but my prog is a pure Win32 app... In that case there is a
dead code in my binary image.... I wonder if there are another surprises...

[]s
Fred