Wireshark mailing list archives

Re: Troubles with ASN generated code


From: Guy Harris <guy () alum mit edu>
Date: Sun, 21 May 2017 12:57:42 -0700

On May 21, 2017, at 12:43 PM, Graham Bloice <graham.bloice () trihedral com> wrote:

I haven't looked at the specific issue, but Windows can export data from a DLL into another DLL.

Yes, but if DLL A exports a data item called "fff" that's imported by DLL B, and DLL B uses it in this fashion:

        static struct xyzzy foo {
                ...

                &fff,

                ...

        };

will that work?  You might be able to do

        xxx = fff;

but can you take the address of the exported item and use that to initialize a pointer in a static data structure.

And will it work if DLL B is loaded at run time?

That's the specific issue here.

The data to be exported should be declared __declspec(dllexport),

That's WS_DLL_PUBLIC_DEF from ws_symbol_export.h, if we're building for Windows with MSVC and WS_BUILD_DLL is defined.

and when it is required to be imported declared as __declspec(dllimport).

That's WS_DLL_PUBLIC_DEF from ws_symbol_export.h, if  we're building for Windows with MSVC and WS_BUILD_DLL *isn't* 
defined.

WS_DLL_PUBLIC is "WS_DLL_PUBLIC_DEF extern".

So you *declare* data items, in header files, with WS_DLL_PUBLIC, and you *define* them, in source files, with 
WS_DLL_PUBLIC_DEF.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: