Prev: Dialog Editor display slightly different than app's
Next: Video Card Performance Characteristics Effecting Text Glyph Rendering?
From: Giovanni Dicanio on 18 Jan 2010 09:21 "Joseph M. Newcomer" <newcomer(a)flounder.com> ha scritto nel messaggio news:5tq6l5t3l0f822fe6cvu66jegjviubleng(a)4ax.com... > WINAPI is __stdcall, so the names are not _name, but _name@n for n being > the number of > parameter bytes being passed. It would be inappropriate to use __stdcall > if you plan to > use GetProcAddress as you show it. So you have the wrong symbol name. > Don't use WINAPI. > Besides, why are you specifying this has a linkage type that is the same > as a kernel call? > That's what WINAPI means; you should not be defining user functions using > the WINAPI > keyword because you are not implementing kernel calls. Joe: I think that WINAPI (i.e. __stdcall) is used also outside the kernel. For example, user32.dll functions like CreateWindowEx use WINAPI calling convention as well. And the exported names are not decorated, in fact using DUMPBIN /EXPORTS we can see CreateWindowExA/W. Moreover, when you define a COM object, the method of the COM interfaces use __stdcall calling convention (wrapped in macros STDMETHOD and STDMETHODCALLTYPE). To avoid decoration for __stdcall calling convention, the only way (to my limited knowledge) is to use .DEF files. Giovanni
From: Faisal on 18 Jan 2010 09:31 On Jan 18, 9:21 am, "Giovanni Dicanio" <giovanniDOTdica...(a)REMOVEMEgmail.com> wrote: > "Joseph M. Newcomer" <newco...(a)flounder.com> ha scritto nel messaggionews:5tq6l5t3l0f822fe6cvu66jegjviubleng(a)4ax.com... > > > WINAPI is __stdcall, so the names are not _name, but _name@n for n being > > the number of > > parameter bytes being passed. It would be inappropriate to use __stdcall > > if you plan to > > use GetProcAddress as you show it. So you have the wrong symbol name.. > > Don't use WINAPI. > > Besides, why are you specifying this has a linkage type that is the same > > as a kernel call? > > That's what WINAPI means; you should not be defining user functions using > > the WINAPI > > keyword because you are not implementing kernel calls. > > Joe: I think that WINAPI (i.e. __stdcall) is used also outside the kernel.. > For example, user32.dll functions like CreateWindowEx use WINAPI calling > convention as well. > And the exported names are not decorated, in fact using DUMPBIN /EXPORTS we > can see CreateWindowExA/W. > > Moreover, when you define a COM object, the method of the COM interfaces use > __stdcall calling convention (wrapped in macros STDMETHOD and > STDMETHODCALLTYPE). > > To avoid decoration for __stdcall calling convention, the only way (to my > limited knowledge) is to use .DEF files. AFAIK there is one more method. Inside one of the DLL's source code modules, you can add a line #pragma comment(linker, "/export:lr_save_string=_lr_save_string@8") > > Giovanni
From: Joseph M. Newcomer on 18 Jan 2010 12:38 "Kernel" includes KRNL32, USER32, GDI32, ADVAPI32 and several other DLLs that constitute the formal "Win32 Interface". Note that WINAPI is NOT NECESSARILY the same as __stdcall. __stdcall is an implementation specification; WINAPI is an abstract interface, which this week, for the x86, happens to translate as __stdcall. If you want __stdcall, you ask for __stdcall. You should not be using a Microsoft-defined abstraction if the intent is to use __stdcall. Note that I said the choice of "WINAPI" was bad. I did *not* say the choice of __stdcall was bad. The error was in choosing a symbol, WINAPI, which has to do with the abstract kernel interface, and using it in a user-level program. The only time this should be used is when the formal specification says that there is a function which the kernel calls which must be declared as WINAPI, and that is actually rare, but again, it is part of the abstract specification of the interface to the kernel (in the opposite direction). The choice of __stdcall was bad for a different reason: the names are not easily used by GetProcAddress, but that is not related to the use of the symbol WINAPI. Note that .DEF files have nothing to do with this. A .DEF file will eliminate the need for __declspec(dllexport), but at considerable inconvenience. But .DEF files are for the linker; they don't tell the compiler how to generate the calling sequence. joe On Mon, 18 Jan 2010 15:21:06 +0100, "Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote: >"Joseph M. Newcomer" <newcomer(a)flounder.com> ha scritto nel messaggio >news:5tq6l5t3l0f822fe6cvu66jegjviubleng(a)4ax.com... > >> WINAPI is __stdcall, so the names are not _name, but _name@n for n being >> the number of >> parameter bytes being passed. It would be inappropriate to use __stdcall >> if you plan to >> use GetProcAddress as you show it. So you have the wrong symbol name. >> Don't use WINAPI. >> Besides, why are you specifying this has a linkage type that is the same >> as a kernel call? >> That's what WINAPI means; you should not be defining user functions using >> the WINAPI >> keyword because you are not implementing kernel calls. > >Joe: I think that WINAPI (i.e. __stdcall) is used also outside the kernel. >For example, user32.dll functions like CreateWindowEx use WINAPI calling >convention as well. >And the exported names are not decorated, in fact using DUMPBIN /EXPORTS we >can see CreateWindowExA/W. > >Moreover, when you define a COM object, the method of the COM interfaces use >__stdcall calling convention (wrapped in macros STDMETHOD and >STDMETHODCALLTYPE). > >To avoid decoration for __stdcall calling convention, the only way (to my >limited knowledge) is to use .DEF files. > >Giovanni > > Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Joseph M. Newcomer on 18 Jan 2010 12:40 Yes. This is the same as the use of the EXPORTS clause in the .DEF file. In most cases, is even clumsier to use than .DEF files. joe On Mon, 18 Jan 2010 06:31:02 -0800 (PST), Faisal <faisalm83(a)gmail.com> wrote: >On Jan 18, 9:21�am, "Giovanni Dicanio" ><giovanniDOTdica...(a)REMOVEMEgmail.com> wrote: >> "Joseph M. Newcomer" <newco...(a)flounder.com> ha scritto nel messaggionews:5tq6l5t3l0f822fe6cvu66jegjviubleng(a)4ax.com... >> >> > WINAPI is __stdcall, so the names are not _name, but _name@n for n being >> > the number of >> > parameter bytes being passed. �It would be inappropriate to use __stdcall >> > if you plan to >> > use GetProcAddress as you show it. �So you have the wrong symbol name. >> > Don't use WINAPI. >> > Besides, why are you specifying this has a linkage type that is the same >> > as a kernel call? >> > That's what WINAPI means; you should not be defining user functions using >> > the WINAPI >> > keyword because you are not implementing kernel calls. >> >> Joe: I think that WINAPI (i.e. __stdcall) is used also outside the kernel. >> For example, user32.dll functions like CreateWindowEx use WINAPI calling >> convention as well. >> And the exported names are not decorated, in fact using DUMPBIN /EXPORTS we >> can see CreateWindowExA/W. >> >> Moreover, when you define a COM object, the method of the COM interfaces use >> __stdcall calling convention (wrapped in macros STDMETHOD and >> STDMETHODCALLTYPE). >> >> To avoid decoration for __stdcall calling convention, the only way (to my >> limited knowledge) is to use .DEF files. > >AFAIK there is one more method. >Inside one of the DLL's source code modules, you can add a line >#pragma comment(linker, "/export:lr_save_string=_lr_save_string@8") >> >> Giovanni Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Stephen Myers on 18 Jan 2010 13:02
Faisal wrote: > On Jan 18, 9:21 am, "Giovanni Dicanio" > <giovanniDOTdica...(a)REMOVEMEgmail.com> wrote: >> "Joseph M. Newcomer" <newco...(a)flounder.com> ha scritto nel messaggionews:5tq6l5t3l0f822fe6cvu66jegjviubleng(a)4ax.com... >> >>> WINAPI is __stdcall, so the names are not _name, but _name@n for n being >>> the number of >>> parameter bytes being passed. It would be inappropriate to use __stdcall >>> if you plan to >>> use GetProcAddress as you show it. So you have the wrong symbol name.. >>> Don't use WINAPI. >>> Besides, why are you specifying this has a linkage type that is the same >>> as a kernel call? >>> That's what WINAPI means; you should not be defining user functions using >>> the WINAPI >>> keyword because you are not implementing kernel calls. >> Joe: I think that WINAPI (i.e. __stdcall) is used also outside the kernel.. >> For example, user32.dll functions like CreateWindowEx use WINAPI calling >> convention as well. >> And the exported names are not decorated, in fact using DUMPBIN /EXPORTS we >> can see CreateWindowExA/W. >> >> Moreover, when you define a COM object, the method of the COM interfaces use >> __stdcall calling convention (wrapped in macros STDMETHOD and >> STDMETHODCALLTYPE). >> >> To avoid decoration for __stdcall calling convention, the only way (to my >> limited knowledge) is to use .DEF files. > > AFAIK there is one more method. > Inside one of the DLL's source code modules, you can add a line > #pragma comment(linker, "/export:lr_save_string=_lr_save_string@8") >> Giovanni > Is name decoration guaranteed? This looks like the kind of thing which would fail silently because of a compiler change. Steve |