[DLL] Exporting a Function with a decorated name

Windows specific forum
Losee
New User
New User
Posts: 4
Joined: Fri May 04, 2018 9:24 am

[DLL] Exporting a Function with a decorated name

Post by Losee »

Hi all,

is it possible to export function in a PureBasic DLL with a decorated name?

In C++ you could export EnableProductSupport as:

Code: Select all

C++:         void __cdecl product::common::EnableProductSupport(void)
undecorated: ?EnableProductSupport@common@product@@YAXXZ
If I wanted to export that in my PureBasic DLL, how could I do that?

Thank you very much!
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: [DLL] Exporting a Function with a decorated name

Post by RSBasic »

Do you mean ProcedureDLL or ProcedureCDLL? http://www.purearea.net/pb/english/manu ... e/dll.html
Image
Image
Losee
New User
New User
Posts: 4
Joined: Fri May 04, 2018 9:24 am

Re: [DLL] Exporting a Function with a decorated name

Post by Losee »

The calling convention is not really the problem. It could either be stdcall or cdecl.

My trouble is defining the function name to reflect the C++ representation to be able to decorate it accordingly.

Code: Select all

  ProcedureCDLL product::common::EnableProductSupport()
    ; perform some magic ...
  EndProcedure
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [DLL] Exporting a Function with a decorated name

Post by skywalk »

How is this not handled with header files?

Code: Select all

extern "C" {
  #include "myPBdll.h" //a C header, so wrap it in extern "C" 
}
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Losee
New User
New User
Posts: 4
Joined: Fri May 04, 2018 9:24 am

Re: [DLL] Exporting a Function with a decorated name

Post by Losee »

@Skywalk:
What do you mean by "not handled"?

To interoperate with another application I need to create a DLL that exports the described functionname. I cannot change the name and I don't know how to export decorated names with PureBasic, that's why I asked.
Fred
Administrator
Administrator
Posts: 16622
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [DLL] Exporting a Function with a decorated name

Post by Fred »

I don't think you can do that, it's a C++ mangling and PB doesn't support support this when creating a DLL. The closer I could think of is to create a thin wrapper in C++ (another DLL) which will call your DLL.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [DLL] Exporting a Function with a decorated name

Post by skywalk »

Losee wrote:@Skywalk:
What do you mean by "not handled"?

To interoperate with another application I need to create a DLL that exports the described functionname. I cannot change the name and I don't know how to export decorated names with PureBasic, that's why I asked.
The C++ application needs to be recompiled with the appropriate header information to call a C or PB function. If you are saying the C++ application cannot be recompiled, then you have to use other means of interprocess communication like the Clipboard or SendMessage(hwDispatch, WM_COPYDATA, hWnd, &MyCDS).
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Losee
New User
New User
Posts: 4
Joined: Fri May 04, 2018 9:24 am

Re: [DLL] Exporting a Function with a decorated name

Post by Losee »

OK, that's what I thought. My workaround at the moment was to compile my DLL and then use "CFF Explorer" to manually change the Function name to reflect that of the decorated function.

Thanks again.
Post Reply